FAQs and Solutions Related to Analytics Kit Integration - Huawei Developers

How do I know whether the Analytics SDK has been successfully integrated or reported data? What is the meaning of key log content?​
1. Add the following code to enable the logging function before initializing the Analytics SDK:
Code:
HiAnalyticsTools.enableLog ();
2. Add the following code to initialize the Analytics SDK:
Code:
HiAnalyticsInstance instance = HiAnalytics.getInstance (this);
3. Run the app and check whether data has been successfully reported based on the log content.
If the Analytics SDK fails to be integrated or report data:
An error code will be contained in the log, and some log content may be marked in red. Check whether related solutions are available by referring to Result Codes and Integration and Debugging.
If data is successfully reported, the key log content is as follows:
Code:
HiAnalyticsSDK: SendMission=> events PostRequest sendevent TYPE : oper, TAG : _openness_config_tag, resultCode: 200 ,reqID:xxx
In app debug mode, each time data is reported, the following log content is generated:
Code:
HiAnalyticsSDK: DeviceToolsKit=> debugMode enabled.
In app debug mode, if an event cannot be reported, the following log content is generated:
Code:
HiAnalyticsSDK: ReportRingback=> do not enable APIEvt in debug model
What can I do if the error message "client token request miss client id" is displayed during SDK initialization?​​[Error message]​
Code:
HiAnalyticsSDK: TokenAssignment=> SE-003|get token exception on the AGC! java.lang.IllegalArgumentException: client token request miss client id, please check whether the 'agconnect-services.json' is configured correctly
[Root cause]​
The Do not include key switch next to agconnect-services.json in the App information area on the Project settings page is toggled on. As a result, keys including the client key and API key are excluded from the configuration file, but APIs of the AppGallery Connect SDK have not been called to manually configure the key information.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
[Solution]​
If you have enabled Do not include key before downloading the agconnect-services.json file, call APIs of the AppGallery Connect SDK to manually configure the key information. For details, please refer to Setting Parameters Using the Configuration File.
3. What can I do if CE-001 or SE-001 is reported during SDK initialization?​
[Error message]​
Code:
HiAnalyticsSDK: jsonParses=> CE-001|Cannot find productId from agconnect-services.json
HiAnalyticsSDK: InitTask=> SE-001|_openness_config_tag instance config init failed!. param error config params is error
[Root cause]​
The parameters for integrating the SDK are incorrect due to the following reasons:
The agconnect-services.json file is saved in the incorrect path.
Content in the agconnect-services.json file is incomplete, or productId has been modified.
In the app-level build.gradle file, apply plugin: 'com.huawei.agconnect' has not been added, or id 'com.huawei.agconnect' has not been added to plugins.
Note: Add com.huawei.agconnect below com.android.application. Otherwise, an error will be reported.
[Solution]​
Place the agconnect-services.json file in the correct path.
Download the agconnect-services.json file from AppGallery Connect again and use it to replace the original one.
Add the com.huawei.agconnect configuration in the correct place.
You can check the configuration by referring to Integrating the SDK.
Learn more​
Official website of Analytics Kit
Development guide of Analytics Kit

Related

Fix your Analytics Kit integration issue by analyzing logs

Introduction:
In this section let us see what are basic issues faced by developers while integrating HMS analytics kits. Huawei developer sites provide excellent guides to integrate easy way. But if you still end up hitting road blocks please refer below blog, which will help you fix those.
What are the tags to check when analysing analytics kit logs? I have gathered below tags and information from analytics logs, this will help you have better idea about how logic flows in the analytics kit.
Tags/Strings you can search for in the logs:
HiAnalyticsSDK
AAID Processor
Token Processor
regHMSEvent()
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
How to take android logs?
In general, taking android logs you will get lot of information regarding the other applications and system infos. To filter analytics sdk specific logs, search for HiAnalyticsSDK tag in android logs. This can narrow down our search a lot.
Code:
adb logcat | findstr "HiAnalyticsSDK"
Are you missing agconnect-services.json?
If you forgot to add agconnect-services.json in the application you will facing this above error. So add your agconnect-services from app-gallery connect. There you go that is straight forward.
Code:
java.lang.RuntimeException: Unable to get provider com.huawei.agconnect.core.provider.AGConnectInitializeProvider: java.security.InvalidParameterException: url is null
Have you enabled the analytics kit in AG-Connect?
If you have forgot to enable Analytics APIs in AG-Connect or if you have setHiAnalyticsInstance.setAnalyticsEnabled(false) the you will have this in your logs.
Code:
HiAnalyticsKit: HiAnalyticsLoginService=> service onBind
HiAnalyticsSDK: HAServiceConnection=> onServiceConnected
HiAnalyticsSDK: HAServiceConnection=> onServiceDisconnected
Enable the Analytics using the API HiAnalyticsInstance.setAnalyticsEnabled(true) and check the logs.and Select any menu under HUAWEI Analytics and click Enable Analytics service. (Only users with the management permission can perform this operation.) Now it will be fine.
Code:
HiAnalyticsKit: HiAnalyticsLoginService=> service onBind
HiAnalyticsSDK: HAServiceConnection=> onServiceConnected
HiAnalyticsSDK: HAServiceConnection=> Upload info is correct
HiAnalyticsKit: HiAnalyticsUtil=> http header pkgName: com.huawei.hms.analytics
HiAnalyticsKit: HiAnalyticsUtil=> analytics sdk start init
Are you facing SHA-ID signature mismatch?
Huawei developer’s portal has easy way to add SHA-ID in your application and AG-Connect. If you somehow messed it up or when the sha-id in AG-Connect and application mismatch, then we will have this error in the logs.
Code:
HiAnalyticsSDK: TokenProcessor=> SE-003|Failed to obtain token from agconnect sdk, token is empty
HiAnalyticsSDK: TokenProcessor=> success: 0
HiAnalyticsSDK: TokenProcessor=> SE-003|Failed to obtain token from agconnect sdk, token is empty
HiAnalyticsSDK: TokenProcessor=> success: 0
HiAnalyticsSDK: EventReportTask=> agc token is empty, stop event report.
Recreate and do the generate signature again to fix the issue
Code:
HiAnalyticsSDK: TokenProcessor=> start get token from agc
HiAnalyticsSDK: AAIDProcessor=> Task<String>.addOnSuccessListener onSuccess!
HiAnalyticsSDK: TokenProcessor=> success: 172800
Is your events not registered?
If you haven't registered the events regHMSEvent() in the code you will face below logs.
Code:
HiAnalyticsSDK AAIDProcessor=> begin sync aaid from opendevice sdk
HiAnalyticsSDK AAIDProcessor=> get aaid success
HiAnalyticsSDK TokenProcessor=> start get token from agc
HiAnalyticsSDK EventRecordTask=> Begin to run EventRecordTask...
HiAnalyticsSDK TokenProcessor=> success: 172800
HiAnalyticsSDK EventRecordTask=> Begin to run EventRecordTask...
HiAnalyticsSDK EventRecordTask=> Begin to run EventRecordTask...
Register your events to fix the issue using regHMSEvent()
Code:
HiAnalyticsSDK AAIDProcessor=> begin sync aaid from opendevice sdk
HiAnalyticsSDK AAIDProcessor=> get aaid success
HiAnalyticsSDK TokenProcessor=> start get token from agc
HiAnalyticsSDK: HiAnalyticsInstanceManager=> regHmsSvcEvent is execute
HiAnalyticsSDK EventRecordTask=> Begin to run EventRecordTask...
HiAnalyticsSDK TokenProcessor=> success: 172800
More details, you can visit https://forums.developer.huawei.com/forumPortal/en/topic/0204400503644150106
How much time it takes to reflect the event on dashboard?

What Can I Do When the Message "miss client id" Is Displayed During AGC

Background
When I referred to official documentation of AppGallery Connect for APM integration and packaged and run the app, an error message was displayed in the run log:
I/com.huawei.agc.apms: failed to fetch remote config: client token request miss client id, please check whether the 'agconnect-services.json' is configured correctly
The log is as follows.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Another colleague encountered this error when integrating App Linking of AppGallery Connect.
According to the error message, I checked the agconnect-services.json file of my demo project. It was found that the client ID in the JSON file was correct.
Problem Reoccurring
First, I downloaded the sample code from the official website and replaced it with my own JSON file. Then, I checked the run logs and found no problem. This meant that the AppGallery Connect project configuration had no problem.
Then, I opened the demo downloaded from the official website, deleted the client ID from the JSON file, and repackaged and run the demo. Two lines of error logs were displayed, which were different from the preceding message. This was not the cause.
Next, I compared the demo project downloaded from the official website with the project created by me. Then, I found that I didn't add the AppGallery Connect plug-in to the app-level build.gradle file, that is, the file did not contain the code as follows.
I deleted the code about the AppGallery Connect plug-in from the gradle file downloaded from the official website. The problem was reproduced.
Cause Analysis
Finally, we communicated with Huawei technical support to find out the root cause of the problem.
During building of the Android project, the AppGallery Connect plug-in in the gradle file automatically compiles the client ID in the JSON file to the String.xml file in the resource directory.
If the AppGallery Connect plug-in is missing, the SDK in the project cannot obtain the client ID.
Solution: Add the AppGallery Connect plug-in to the app-level build.gradle file.
HTML:
apply plugin: 'com.android.application'
apply plugin: 'com.huawei.agconnect'
apply plugin: 'com.huawei.agconnect.apms'
For details about how to integrate the AppGallery Connect plug-in, please refer to the following:
https://developer.huawei.com/consum...nnect-Guides/agc-get-started#h2-1587477308727
I am getting error message during the build.gradle file compilation: "com.huawei.agconnect" not found. Help me to resolve this issue
riteshchanchal said:
I am getting error message during the build.gradle file compilation: "com.huawei.agconnect" not found. Help me to resolve this issue
Click to expand...
Click to collapse
You may refer to the following link to solve the problem: General FAQs

How Can I Integrate Remote Configuration of AppGallery Connect in Cordova?

Recently, it is found that AppGallery Connect Remote Configuration starts to support Cordova. The integration is rather simple, let’s have a try.If you want to quickly experience this service, see the demo on GitHub.
Integration Procedure
1. Create a project directory on your computer, run the following npm command to install Cordova.
npm install -g cordova
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
2. Create a project and enable Remote Configuration.
a) Create an Android app in AppGallery, add it to a project, enable Remote Configuration, and add a parameter.
b) Run the following command to create a Cordova project. In this example, name the project RemoteConfig.
cordova create RemoteDemo com.huawei.cordova.remoteconfig RemoteConfig Creating a new cordova project.
c) Add an app platform to the project.
In the project directory, run cordova platform add android to add the Android platform.
Run cordova platform -l to view the supported platforms.
d) Go to Project settings in AppGallery Connect, download the agconnect-services.json file, and add the file to the android/app directory of your project.
e) Install the AppGallery Connect plug-in.
cordova plugin add @Cordova-plugin-agconnect/remoteconfig --save
After the plug-in is installed, you can view it in the plugins directory.
Add the AppGallery Connect plug-in address to app/build.gradle.
3. Use the Remote Configuration service.
1. Fetch data from the cloud. The data takes effect this time.
Call the fetch API to fetch parameter values from the cloud, and call the apply API to make them take effect.
You can view the fetched parameter values on the cloud in log information.
The other values displayed in log information are local ones.
2. Fetch the cloud data and make the parameter values fetched last time take effect.
Replace the fetch API with applyLastFetch to fetch data that is fetched from the cloud last time.
3. Clear the data.
Call the clearAll API to clear the cached data that is fetched earlier.
4. Fetch the value of a key from the cloud.
Call getValue to fetch related data from the cloud.
4. Compile and install an app package.
Run the cordova build android command to compile the project.
Find the APK package in the build folder in the android directory.
For more details, please check:
Cordova documentation:
https://cordova.apache.org/docs/en/latest/guide/platforms/android/index.html
Remote Configuration API Reference:
https://github.com/AppGalleryConnect/agc-demos/tree/main/Cordova/agc-remoteconfig-cordova
Remote Configuration Demo:
https://github.com/AppGalleryConnect/agc-demos/tree/main/Cordova/agc-remoteconfig-cordova

Three Steps to Rectify Failure in Creating Cloud DB Object Types

Relevant Logs​You may encounter a failure to create object types when integrating Cloud DB. Typical logs are as follows:
1. The ObjectType quantity is invalid.
XML:
NaturalBase: GenerateDiffSchemas: remove ObjectType is not supported. count of ObjectType is less than current
2. The object types failed to be negotiated.
XML:
E/NaturalBase: OpenNaturalStore: negotiate failed.
W/AGConnectCloudDB: openCloudDBZone: failed to create or open a cloudDBZone.
3. The scheme is not synchronized.
XML:
[NaturalCloudSyncModule][OnConnected]: negotiate schema.
[PushMessageAndNotifyStoreCv] Schema is UnSynced
4. The version of object types been changed but object types themselves are not changed.
XML:
E/NaturalBase: CreateObjectType: ObjectType version has changed, but ObjectType has not changed.
E/AGConnectCloudDB: createObjectType: failed to create ObjectType into the AGCConnectCloudDB.
Cause Analysis​The main cause is that the file matching the object type version in your Android project is inconsistent with the object types set on the AppGallery Connect server.
You can check the object types in AppGallery Connect as follows.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
To check information relevant to object types in your Android project, check the class in ObjectTypeInfoHelper.
Three Steps to Solve the Problem​1. Exporting Object Types from AppGallery Connect​Since the object types in your Android project are inconsistent with those in AppGallery Connect, you need to export the object types from AppGallery Connect for synchronization.
The export procedure in AppGallery Connect is as follows: Sign in to AppGallery Connect, click My projects, click your project, go to Build > Cloud DB > ObjectTypes, select the specific version, and click Export.
During the export, select JAVA for the file format and android for the file type of Java, and enter a package name.
Decompress the exported ZIP package in your project directory.
2. Checking Versions​You should pay attention to two versions in the object type file, which correspond to the following two fields in the ObjectTypeInfoHelper file:
1. FORMAT_VERSION: The value should match the SDK version.
If the value of FORMAT_VERSION in the exported file is 1, integrate the Cloud DB SDK of a version earlier than 1.2.2. Version 1.2.1.301 is recommended.
If the value of FORMAT_VERSION in the exported file is 2, integrate the Cloud DB SDK of a later version. Version 1.2.3.301 is recommended.
2. OBJECT_TYPE_VERSION
This version is that selected when you export object type information from AppGallery Connect. Generally, you do not need to change it.
3. Uninstalling Your App from Your Device and Installing It Again​If you have encountered the object type problem on your device, the incorrect information will still exist in the cache if you install your app again directly, and object type creation will still fail.
The correct method for performing the app re-installation is as follows:
1. Package your app again.
2. Uninstall the app already installed on your device manually.
3. Install the newly packaged app on your device for debugging.
The correct method for performing the app re-installation is as follows:
https://developer.huawei.com/consum...ect-Guides/agc-clouddb-agcconsole-objecttypes

Analyzing and Solving Error 907135701 from HMS Core Account Kit

907135701 is one of the most frequently reported error codes from HMS Core Account Kit. The official document describes the error as follows.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Both an Android project and a HarmonyOS project can report this error.
I myself have come across it several times and have summed up some of the causes and solutions for it, as follows.
From an Android Project​Cause 1: The app information is not configured in AppGallery Connect, and the app ID is not generated.
Solution: Configure the app information in AppGallery Connect.
To do this, first register as a Huawei developer and complete identity verification on HUAWEI Developers, as detailed here. Create a project and an app as needed and then obtain the app ID in AppGallery Connect.
Cause 2: The sign certificate fingerprint is not configured or incorrectly configured.
Solution: Verify that the fingerprint configured in AppGallery Connect and the fingerprint used during app packaging are consistent. You can configure the fingerprint by referring to this document.
Cause 3: agconnect-services.json is incorrectly configured, or this file is not placed in the correct directory.
Solution: Verify that the app IDs in agconnect-services.json and AppGallery Connect are the same, and copy the file to the app directory.
Also note that unless necessary, do not toggle on Do not include key in AppGallery Connect.
To re-configure the file, follow the instructions here.
From a HarmonyOS (Java) Project​Cause 1: agconnect-services.json is not placed in a proper directory.
Solution: Move the file to the entry directory.
Cause 2: The sign certificate fingerprint is not configured or incorrectly configured.
Solution: Verify that the fingerprint is configured as specified in Configuring App Signing. After obtaining the fingerprint, verify that it is consistent with that in AppGallery Connect.
Cause 3: The attribute configuration of config.json is incorrect.
Solution: Add the following content to module in the entry/src/main/config.json file of the HarmonyOS app. Do not change the value of name.
Code:
"metaData": {
"customizeData": [
{
"name": "com.huawei.hms.client.appid",
// Replace OAuth Client ID with your actual ID.
"value": "OAuth Client ID" //
}
]
}
Cause 4: The plugin configuration is incorrect.
Solution: Add the AppGallery Connect plugin configuration through either of these methods:
Method 1: Add the following configuration under the declaration in the file header:
Code:
apply plugin: 'com.huawei.agconnect'
Method 2: Add the plugin configuration in the plugins block.
Code:
plugins {
id 'com.android.application'
// Add the following configuration:
id 'com.huawei.agconnect'
}
References​HMS Core Account Kit home page
HMS Core Account Kit Development Guide

Categories

Resources