Skip to content

Commit e1ba4e7

Browse files
authored
Fix issue with Android package name (#266)
* Replace the package name in the Android srcaar * Update build_aar.cmake * Fix python script, and update version number
1 parent dcde678 commit e1ba4e7

File tree

5 files changed

+31
-3
lines changed

5 files changed

+31
-3
lines changed

aar_builder/build_aar.py

+21-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
# limitations under the License.
1414
"""Combines some base files and the given files into an aar file."""
1515

16+
import re
17+
import shutil
18+
import tempfile
1619
import os
1720
import zipfile
1821
from absl import app
@@ -37,6 +40,8 @@
3740
flags.DEFINE_string("classes_jar", None,
3841
"Location of the classes.jar file to include " +
3942
"in the aar. A default is used if not provided.")
43+
flags.DEFINE_string("manifest_package_name", None,
44+
"Package name to overwrite the AndroidManifest with.")
4045

4146

4247
def main(unused_argv):
@@ -59,6 +64,21 @@ def main(unused_argv):
5964
if FLAGS.classes_jar:
6065
classes_jar_file = os.path.normcase(FLAGS.classes_jar)
6166

67+
# Edit the AndroidManifest file, replacing the package name
68+
# with the provided one
69+
temp_dir = tempfile.mkdtemp()
70+
patched_manifest = shutil.copy(android_manifest_file, temp_dir)
71+
if FLAGS.manifest_package_name:
72+
with open(patched_manifest, "r") as new_file:
73+
contents = new_file.read()
74+
75+
contents = re.sub('package=".+"',
76+
'package="%s"' % FLAGS.manifest_package_name,
77+
contents)
78+
79+
with open(patched_manifest, "w") as new_file:
80+
new_file.write(contents)
81+
6282
# Delete the aar file, if it already exists
6383
if os.path.exists(output_file):
6484
os.remove(output_file)
@@ -79,7 +99,7 @@ def main(unused_argv):
7999

80100
with zipfile.ZipFile(output_file, "w") as myzip:
81101
# Write the generic base files that are required in an aar file.
82-
myzip.write(android_manifest_file, "AndroidManifest.xml")
102+
myzip.write(patched_manifest, "AndroidManifest.xml")
83103
myzip.write(classes_jar_file, "classes.jar")
84104
myzip.write(os.path.join(file_dir, "R.txt"), "R.txt")
85105
myzip.writestr("res/", "")

cmake/build_aar.cmake

+3-1
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ set(MAVEN_TEMPLATE ${CMAKE_CURRENT_LIST_DIR}/maven.template)
3333
# Optional Args:
3434
# ANDROID_MANIFEST: The custom AndroidManifest file to include.
3535
# CLASSES_JAR: The custom classes.jar file to include.
36+
# MANIFEST_PACKAGE_NAME: Package name to overwrite the AndroidManifest with.
3637
function(build_aar LIBRARY_NAME LIBRARY_TARGET PROGUARD_TARGET
3738
ARTIFACT_ID VERSION)
3839
# Parse the additional arguments
39-
set(single ANDROID_MANIFEST CLASSES_JAR)
40+
set(single ANDROID_MANIFEST CLASSES_JAR MANIFEST_PACKAGE_NAME)
4041
cmake_parse_arguments(BUILD_AAR_ARGS "" "${single}" "" ${ARGN})
4142

4243
set(AAR_NAME "${ARTIFACT_ID}-${VERSION}")
@@ -51,6 +52,7 @@ function(build_aar LIBRARY_NAME LIBRARY_TARGET PROGUARD_TARGET
5152
"--proguard_file=${${PROGUARD_TARGET}}"
5253
"--android_manifest=${BUILD_AAR_ARGS_ANDROID_MANIFEST}"
5354
"--classes_jar=${BUILD_AAR_ARGS_CLASSES_JAR}"
55+
"--manifest_package_name=${BUILD_AAR_ARGS_MANIFEST_PACKAGE_NAME}"
5456
DEPENDS
5557
"${LIBRARY_TARGET}"
5658
"${PROGUARD_TARGET}"

cmake/build_firebase_aar.cmake

+2
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,7 @@ function(build_firebase_aar LIBRARY_NAME ARTIFACT_NAME LIBRARY_TARGET
4747
${FIREBASE_AAR_ARGS_ANDROID_MANIFEST}
4848
CLASSES_JAR
4949
${FIREBASE_AAR_ARGS_CLASSES_JAR}
50+
MANIFEST_PACKAGE_NAME
51+
"com.google.firebase.unity.${LIBRARY_NAME}"
5052
)
5153
endfunction()

cmake/firebase_unity_version.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
# This file defines the version numbers used by the Firebase Unity SDK.
1616

17-
set(FIREBASE_UNITY_SDK_VERSION "8.10.0"
17+
set(FIREBASE_UNITY_SDK_VERSION "8.10.1"
1818
CACHE STRING "The version of the Unity SDK, used in the names of files.")
1919

2020
set(FIREBASE_IOS_POD_VERSION "8.15.0"

docs/readme.md

+4
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ Support
163163

164164
Release Notes
165165
-------------
166+
### 8.10.1
167+
- Changes
168+
- General (Android): Fix an issue when building with mainTemplate.gradle.
169+
166170
### 8.10.0
167171
- Changes
168172
- General (Editor, macOS): Fix an issue when finding "python" executable.

0 commit comments

Comments
 (0)