Skip to content

Commit 93bd2e9

Browse files
authored
Package the Messaging java file and aar separately (#626)
* Package the Messaging java file and aar separately * Add a custom target for the aar * Update exports.json * Add the java files to the Messaging packaging * Update readme.md * Update unity_pack.cmake
1 parent b513916 commit 93bd2e9

File tree

9 files changed

+70
-18
lines changed

9 files changed

+70
-18
lines changed

cmake/android_dependencies.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ set(FIREBASE_MESSAGING_ANDROID_DEPS
6565
"com.google.firebase:firebase-messaging:23.1.2"
6666
"com.google.firebase:firebase-analytics:21.2.0"
6767
"com.google.firebase:firebase-iid:21.1.0"
68+
"com.google.flatbuffers:flatbuffers-java:1.12.0"
6869
)
6970

7071
set(FIREBASE_REMOTE_CONFIG_ANDROID_DEPS

cmake/unity_pack.cmake

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -298,29 +298,40 @@ endfunction()
298298
#
299299
# unity_pack_file(<file>
300300
# PACK_PATH
301+
# RENAME_TO
301302
# )
302303
#
303304
# Args:
304305
# file: Path of file to pack
305-
# pack_path: Destination to put the file in.
306+
# PACK_PATH: Destination to put the file in.
307+
# RENAME_TO: Optional parameter to rename the file.
306308
#
307309
# Notes:
308310
# * Files are put into build arch folder
309311
#
310312
function(unity_pack_file file)
311-
set(multi PACK_PATH)
312-
# Parse the arguments into UNITY_MONO_SOURCES and UNITY_MONO_DEPENDS.
313-
cmake_parse_arguments(UNITY_PACK "" "" "${multi}" ${ARGN})
313+
set(single PACK_PATH RENAME_TO)
314+
# Parse the arguments into UNITY_PACK_*.
315+
cmake_parse_arguments(UNITY_PACK "" "${single}" "" ${ARGN})
314316

315317
if("${UNITY_PACK_PACK_PATH}" STREQUAL "")
316318
set(UNITY_PACK_PACK_PATH ${UNITY_PACK_DEFAULT_CS_PATH})
317319
endif()
318320

319-
# meta file
320-
install(
321-
FILES ${file}
322-
DESTINATION ${UNITY_PACK_PACK_PATH}
323-
)
321+
# Install the file to the PACK_PATH, renaming it if given RENAME_TO
322+
if ("${UNITY_PACK_RENAME_TO}" STREQUAL "")
323+
# Install the file to the PACK_PATH
324+
install(
325+
FILES ${file}
326+
DESTINATION ${UNITY_PACK_PACK_PATH}
327+
)
328+
else()
329+
install(
330+
FILES ${file}
331+
DESTINATION ${UNITY_PACK_PACK_PATH}
332+
RENAME ${UNITY_PACK_RENAME_TO}
333+
)
334+
endif()
324335
endfunction()
325336

326337
# Packs a aar file into the unity zip

docs/readme.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ Support
6969

7070
Release Notes
7171
-------------
72+
### Upcoming
73+
- Changes
74+
- Messaging (Android): Provide the custom MessagingUnityPlayerActivity
75+
as a Java file instead of precompiling it. This is to better support
76+
changes with the UnityPlayerActivity in the Unity 2023 editor.
77+
7278
### 10.6.0
7379
- Changes
7480
- General (Android): Update to Firebase Android BoM version 31.2.3.

messaging/CMakeLists.txt

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ build_firebase_shared(
7171
FirebaseCppMessaging
7272
ANDROID_MANIFEST
7373
"${CMAKE_CURRENT_LIST_DIR}/AndroidManifest.xml"
74-
CLASSES_JAR
75-
"${CMAKE_CURRENT_LIST_DIR}/activity/classes.jar"
7674
)
7775
endif()
7876

@@ -89,6 +87,29 @@ if (FIREBASE_INCLUDE_UNITY)
8987
)
9088
endif()
9189

90+
if (ANDROID)
91+
# Add the additional Messaging files needed for Android
92+
unity_pack_file(
93+
"activity/com/google/firebase/MessagingUnityPlayerActivity.java"
94+
PACK_PATH
95+
"Firebase/Plugins/Android/"
96+
)
97+
# Get the Messaging Java AAR file from the C++ SDK.
98+
add_custom_target(
99+
firebase_messaging_java_aar_unity
100+
ALL
101+
DEPENDS firebase_messaging_java_aar
102+
)
103+
get_target_property(messaging_aar_file firebase_messaging_java_aar OBJECT_OUTPUTS)
104+
unity_pack_file(
105+
${messaging_aar_file}
106+
PACK_PATH
107+
"Firebase/Plugins/Android/"
108+
RENAME_TO
109+
"firebase-messaging-cpp.aar"
110+
)
111+
endif()
112+
92113
set_property(TARGET firebase_messaging_cs
93114
PROPERTY FOLDER
94115
"Firebase ${FIREBASE_PLATFORM_NAME}"

messaging/activity/README.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

messaging/activity/classes.jar

-82.6 KB
Binary file not shown.

unity_packer/debug_single_export_json/messaging.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,15 @@
296296
"Firebase/Plugins/x86_64/FirebaseCppMessaging*"
297297
]
298298
},
299+
{
300+
"importer": "PluginImporter",
301+
"platforms": ["Android"],
302+
"cpu": "AnyCPU",
303+
"paths": [
304+
"Firebase/Plugins/Android/MessagingUnityPlayerActivity.java",
305+
"Firebase/Plugins/Android/firebase-messaging-cpp.aar"
306+
]
307+
},
299308
{
300309
"importer": "DefaultImporter",
301310
"paths": [

unity_packer/exports.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,15 @@
742742
"Firebase/Plugins/x86_64/FirebaseCppMessaging*"
743743
]
744744
},
745+
{
746+
"importer": "PluginImporter",
747+
"platforms": ["Android"],
748+
"cpu": "AnyCPU",
749+
"paths": [
750+
"Firebase/Plugins/Android/MessagingUnityPlayerActivity.java",
751+
"Firebase/Plugins/Android/firebase-messaging-cpp.aar"
752+
]
753+
},
745754
{
746755
"importer": "DefaultImporter",
747756
"paths": ["Firebase/Editor/FirebaseMessaging*_manifest.txt"]

unity_packer/guids.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,8 @@
437437
"Firebase/Editor/FirebaseMessaging_version-10.4.0_manifest.txt": "b3485828d4234137a8280f00a1f7b9ee",
438438
"Firebase/Editor/FirebaseRemoteConfig_version-10.4.0_manifest.txt": "b2256be1dfd54952908252655336b218",
439439
"Firebase/Editor/FirebaseStorage_version-10.4.0_manifest.txt": "981f0090257a44369332d6a7437869f3",
440+
"Firebase/Plugins/Android/MessagingUnityPlayerActivity.java": "794c5e69320a44ca9d01f87f1019164e",
441+
"Firebase/Plugins/Android/firebase-messaging-cpp.aar": "0be2cda49adc4b61a7e9eb9bf669fdab",
440442
"Firebase/Plugins/x86_64/FirebaseCppApp-10_4_0.bundle": "377df3b93de5491f8ca5dd75a1c63285",
441443
"Firebase/Plugins/x86_64/FirebaseCppApp-10_4_0.dll": "6008badfe2a9454c897af3b59668d865",
442444
"Firebase/Plugins/x86_64/FirebaseCppApp-10_4_0.so": "e2c049b2b0a44e3cb32171ad383d7bb1",

0 commit comments

Comments
 (0)