@htlxyz
We found 2 problem of import firebase.
- Send message to Google Analytics success only in debug build
- Got some error log in logcat, even if the send message to Google Analytics success
Problem 1: run google analytics of firebase without problem
Here is our operation for building a debug apk:
- Create project, adding TS file to connecting firebase for google analytics using
- Build project, set ‘debug’ in build config
- Download SDKBox from store and install SDKBox in Extension Manager
- Import Firebase via SDKBox
- Firebase for android config
file \build\android\proj\build.gradle
of proj, follow the guide
...
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
// add this line
classpath 'com.google.gms:google-services:4.3.5' // Google Services plugin
...
file `\native\engine\android\app\build.gradle of app
apply plugin: 'com.android.application'
\\ add this line
apply plugin: 'com.google.gms.google-services' // Google Services plugin
...
dependencies {
implementation 'com.google.firebase:firebase-analytics:17.4.4'
\\ add this line
implementation platform('com.google.firebase:firebase-bom:27.1.0')
}
...
file \build\android\proj\gradle.properties
...
PROP_COMPILE_SDK_VERSION=28 // It doesn't have to be set to 28, as long as the compile, target, tool are consistent.
PROP_MIN_SDK_VERSION=16
PROP_TARGET_SDK_VERSION=28
PROP_BUILD_TOOLS_VERSION=28.0.2
...
android.useAndroidX=true
Here has one question, why the PROP_COMPILE_SDK_VERSION
and PROP_TARGET_SDK_VERSION
will rollback to 27
, is there a config to make this always be 30
after each time of build project.
- Binding Firebase, make sure the jsb bind, file
\native\engine\common\Classes\jsb_module_register.cpp
...
#include "cocos/bindings/manual/jsb_xmlhttprequest.h"
// js-binding-Firebase, add below two lines
#include "PluginFirebaseJS.hpp"
#include "PluginFirebaseJSHelper.h"
#if USE_GFX_RENDERER
#endif
...
se->addRegisterCallback(register_all_pipeline_manual);
// js-binding-Firebase, add below two lines
se->addRegisterCallback(register_all_PluginFirebaseJS);
se->addRegisterCallback(register_all_PluginFirebaseJS_helper);
#if (CC_PLATFORM == CC_PLATFORM_MAC_IOS || CC_PLATFORM == CC_PLATFORM_MAC_OSX)
se->addRegisterCallback(register_javascript_objc_bridge);
#endif
...
- Make project, generate apk
- Run project, install apk on android device and launch app
Got unknown plugin: Firebase
error log, but google analytics receive the logEvent successfully
2021-05-12 12:03:38.030 16251-16321/com.abc.cde.dev E/SDKBOX_CORE: Checking plugin status for unknown plugin: Firebase
2021-05-12 12:03:38.031 16251-16321/com.abc.cde.dev W/System.err: java.lang.ClassNotFoundException: Didn't find class "com.sdkbox.plugin.SdkboxLog" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/system/lib, /system/product/lib, /oppo_product/lib, /system/lib, /system/product/lib, /oppo_product/lib]]
2021-05-12 12:03:38.031 16251-16321/com.abc.cde.dev W/System.err: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
2021-05-12 12:03:38.031 16251-16321/com.abc.cde.dev W/System.err: at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
2021-05-12 12:03:38.031 16251-16321/com.abc.cde.dev W/System.err: at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
2021-05-12 12:03:38.032 16251-16321/com.abc.cde.dev W/System.err: java.lang.ClassNotFoundException: Didn't find class "com.sdkbox.plugin.SDKBox" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/system/lib, /system/product/lib, /oppo_product/lib, /system/lib, /system/product/lib, /oppo_product/lib]]
2021-05-12 12:03:38.032 16251-16321/com.abc.cde.dev W/System.err: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
2021-05-12 12:03:38.032 16251-16321/com.abc.cde.dev W/System.err: at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
2021-05-12 12:03:38.032 16251-16321/com.abc.cde.dev W/System.err: at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
2021-05-12 12:03:38.032 16251-16321/com.abc.cde.dev I/SDKBOX_CORE: Initialization request for plugin: 'com/sdkbox/plugin/firebase/Analytics/Analytics'
- Re-make project, execute step 4, 6, and 7
Got different error log, but google analytics receive the logEvent successfully
2021-05-12 12:16:25.477 20214-20300/com.abc.cde.dev D/jswrapper: JS: bangyno init e
2021-05-12 12:16:25.478 20214-20300/com.abc.cde.dev W/System.err: java.lang.ClassNotFoundException: Didn't find class "com.sdkbox.plugin.TrackingInfoAndroid" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/system/lib, /system/product/lib, /oppo_product/lib, /system/lib, /system/product/lib, /oppo_product/lib]]
2021-05-12 12:16:25.478 20214-20300/com.abc.cde.dev W/System.err: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
2021-05-12 12:16:25.478 20214-20300/com.abc.cde.dev W/System.err: at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
2021-05-12 12:16:25.478 20214-20300/com.abc.cde.dev W/System.err: at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
2021-05-12 12:16:25.479 20214-20300/com.abc.cde.dev W/System.err: java.lang.ClassNotFoundException: Didn't find class "com.sdkbox.plugin.TrackingInfoAndroid" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/system/lib, /system/product/lib, /oppo_product/lib, /system/lib, /system/product/lib, /oppo_product/lib]]
2021-05-12 12:16:25.479 20214-20300/com.abc.cde.dev W/System.err: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
2021-05-12 12:16:25.479 20214-20300/com.abc.cde.dev W/System.err: at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
2021-05-12 12:16:25.480 20214-20300/com.abc.cde.dev W/System.err: at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
Here is the question, what is the error and we need to care this error log?
Problem 2: build release apk for google analytics of firebase
Our final goal is build a release apk, but now we only could build a debug apk for google analytics of firebase.
Follow the steps 1-8 but skip step 2, we build the release apk.
Got unknown plugin: Firebase
error log, and google analytics logEvent didn’t receive
2021-05-12 11:57:20.326 14332-14390/? E/SDKBOX_CORE: Checking plugin status for unknown plugin: Firebase
2021-05-12 11:57:20.326 14332-14390/? W/System.err: java.lang.ClassNotFoundException: com.sdkbox.plugin.SdkboxLog
2021-05-12 11:57:20.326 14332-14390/? W/System.err: java.lang.NoSuchMethodError: no static method "Lcom/sdkbox/plugin/SdkboxLog;.NewLog(Ljava/lang/String;)V"
2021-05-12 11:57:20.326 14332-14390/? E/SDKBOX_CORE: JNI_BRIDGE Not found static method NewLog, for clazz com/sdkbox/plugin/SdkboxLog and signature (Ljava/lang/String;)V
What is the problem?
Could you give us some guide?
Thanks.