What Can I Do When the Message “miss client id” Is Displayed During AppGallery Connect Service Integration?
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.
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.
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.
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.
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: