From e1ba4e7e87ff11718b11f8d8b492b4a0a83c948a Mon Sep 17 00:00:00 2001 From: a-maurice Date: Tue, 3 May 2022 16:15:57 -0700 Subject: [PATCH] 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 --- aar_builder/build_aar.py | 22 +++++++++++++++++++++- cmake/build_aar.cmake | 4 +++- cmake/build_firebase_aar.cmake | 2 ++ cmake/firebase_unity_version.cmake | 2 +- docs/readme.md | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/aar_builder/build_aar.py b/aar_builder/build_aar.py index 64428eb0..56afff50 100644 --- a/aar_builder/build_aar.py +++ b/aar_builder/build_aar.py @@ -13,6 +13,9 @@ # limitations under the License. """Combines some base files and the given files into an aar file.""" +import re +import shutil +import tempfile import os import zipfile from absl import app @@ -37,6 +40,8 @@ flags.DEFINE_string("classes_jar", None, "Location of the classes.jar file to include " + "in the aar. A default is used if not provided.") +flags.DEFINE_string("manifest_package_name", None, + "Package name to overwrite the AndroidManifest with.") def main(unused_argv): @@ -59,6 +64,21 @@ def main(unused_argv): if FLAGS.classes_jar: classes_jar_file = os.path.normcase(FLAGS.classes_jar) + # Edit the AndroidManifest file, replacing the package name + # with the provided one + temp_dir = tempfile.mkdtemp() + patched_manifest = shutil.copy(android_manifest_file, temp_dir) + if FLAGS.manifest_package_name: + with open(patched_manifest, "r") as new_file: + contents = new_file.read() + + contents = re.sub('package=".+"', + 'package="%s"' % FLAGS.manifest_package_name, + contents) + + with open(patched_manifest, "w") as new_file: + new_file.write(contents) + # Delete the aar file, if it already exists if os.path.exists(output_file): os.remove(output_file) @@ -79,7 +99,7 @@ def main(unused_argv): with zipfile.ZipFile(output_file, "w") as myzip: # Write the generic base files that are required in an aar file. - myzip.write(android_manifest_file, "AndroidManifest.xml") + myzip.write(patched_manifest, "AndroidManifest.xml") myzip.write(classes_jar_file, "classes.jar") myzip.write(os.path.join(file_dir, "R.txt"), "R.txt") myzip.writestr("res/", "") diff --git a/cmake/build_aar.cmake b/cmake/build_aar.cmake index b43e9fc0..6f06ca98 100644 --- a/cmake/build_aar.cmake +++ b/cmake/build_aar.cmake @@ -33,10 +33,11 @@ set(MAVEN_TEMPLATE ${CMAKE_CURRENT_LIST_DIR}/maven.template) # Optional Args: # ANDROID_MANIFEST: The custom AndroidManifest file to include. # CLASSES_JAR: The custom classes.jar file to include. +# MANIFEST_PACKAGE_NAME: Package name to overwrite the AndroidManifest with. function(build_aar LIBRARY_NAME LIBRARY_TARGET PROGUARD_TARGET ARTIFACT_ID VERSION) # Parse the additional arguments - set(single ANDROID_MANIFEST CLASSES_JAR) + set(single ANDROID_MANIFEST CLASSES_JAR MANIFEST_PACKAGE_NAME) cmake_parse_arguments(BUILD_AAR_ARGS "" "${single}" "" ${ARGN}) set(AAR_NAME "${ARTIFACT_ID}-${VERSION}") @@ -51,6 +52,7 @@ function(build_aar LIBRARY_NAME LIBRARY_TARGET PROGUARD_TARGET "--proguard_file=${${PROGUARD_TARGET}}" "--android_manifest=${BUILD_AAR_ARGS_ANDROID_MANIFEST}" "--classes_jar=${BUILD_AAR_ARGS_CLASSES_JAR}" + "--manifest_package_name=${BUILD_AAR_ARGS_MANIFEST_PACKAGE_NAME}" DEPENDS "${LIBRARY_TARGET}" "${PROGUARD_TARGET}" diff --git a/cmake/build_firebase_aar.cmake b/cmake/build_firebase_aar.cmake index d46a397d..f16d3789 100644 --- a/cmake/build_firebase_aar.cmake +++ b/cmake/build_firebase_aar.cmake @@ -47,5 +47,7 @@ function(build_firebase_aar LIBRARY_NAME ARTIFACT_NAME LIBRARY_TARGET ${FIREBASE_AAR_ARGS_ANDROID_MANIFEST} CLASSES_JAR ${FIREBASE_AAR_ARGS_CLASSES_JAR} + MANIFEST_PACKAGE_NAME + "com.google.firebase.unity.${LIBRARY_NAME}" ) endfunction() diff --git a/cmake/firebase_unity_version.cmake b/cmake/firebase_unity_version.cmake index 99aa7c32..f1c12465 100644 --- a/cmake/firebase_unity_version.cmake +++ b/cmake/firebase_unity_version.cmake @@ -14,7 +14,7 @@ # This file defines the version numbers used by the Firebase Unity SDK. -set(FIREBASE_UNITY_SDK_VERSION "8.10.0" +set(FIREBASE_UNITY_SDK_VERSION "8.10.1" CACHE STRING "The version of the Unity SDK, used in the names of files.") set(FIREBASE_IOS_POD_VERSION "8.15.0" diff --git a/docs/readme.md b/docs/readme.md index 77871aa0..3cd9e00a 100644 --- a/docs/readme.md +++ b/docs/readme.md @@ -163,6 +163,10 @@ Support Release Notes ------------- +### 8.10.1 +- Changes + - General (Android): Fix an issue when building with mainTemplate.gradle. + ### 8.10.0 - Changes - General (Editor, macOS): Fix an issue when finding "python" executable.