Cause Analysis:
Possible causes are as follows:
The advanced analytics function has not been enabled.
The obtained agconnect-services.json file is not the original file.
The debug mode has not been successfully enabled.
The Logcat log data on the device is not reported successfully.
Solution:
To correct the fault, perform the following steps:
1. Check whether you have enabled the advanced analytics function and the API management function (enabled by default).
2. Check whether the agconnect-services.json file is the original file without any modification.
3. Check whether the debug mode is enabled.
4. Check whether the log data is reported successfully. If the log contains resultCode: 200, the data is reported successfully. The possible causes are as follows:
Case 1: The tools:node parameters is set to "replace" (that is, tools:node="replace"). This causes the app configuration to conflict with AppGallery Connect SDK configurations, and therefore an exception occurs when the AppGallery Connect API is called to obtain the token.
Case 2: The configuration for excluding HUAWEI Analytics Kit from obfuscation is not added before you compile the APK. As a result, an exception occurs during the running of the APK.
For case 1, use the following procedure:
Set tools:node to "merge" (that is, tools:node="merge").
Manually write all information in the AndroidManifest.xml file of AppGallery Connect to the AndroidManifest.xml file of your app.
For case 2, use the following procedure:
Open the obfuscation script file of your project.
Add configurations to exclude HUAWEI Analytics Kit from obfuscation.
- -keep class com.hianalytics.android.**{*;}
- -keep class com.huawei.updatesdk.**{*;}
- -keep class com.huawei.hms.**{*;}
- -keep class com.huawei.agconnect.**{*;}
- -keep interface com.huawei.hms.analytics.type.HAEventType{*;}
- -keep interface com.huawei.hms.analytics.type.HAParamType{*;}
Cause Analysis:
The possible causes are as follows:
You do not have the agconnect-services.json file.
You have not enabled the API permission of HUAWEI Analytics Kit before you download the agconnect-services.json file.
Solution:
For case 1: Sign in to AppGallery Connect and download the agconnect-services.json file.
For case 2: Sign in to AppGallery Connect and go to Project Setting > Manage APIs to enable the API permission.
