jespivigno
jespivigno

Reputation: 89

Cloud DB AGConnectInitializeProvider Error

i wanted to import and use cloud DB client sample app on Android Studio.

https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Examples/agc-clouddb-samplecode

However , i kept getting below app gallery connect releated error:

java.lang.RuntimeException: Unable to get provider com.huawei.agconnect.core.provider.AGConnectInitializeProvider: java.lang.NullPointerException: Attempt to invoke virtual method 'char[] java.lang.String.toCharArray()' on a null object reference

        at android.app.ActivityThread.installProvider(ActivityThread.java:6242)

        at android.app.ActivityThread.installContentProviders(ActivityThread.java:5805)

        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5722)

        at android.app.ActivityThread.-wrap1(Unknown Source:0)

        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)

        at android.os.Handler.dispatchMessage(Handler.java:106)

        at android.os.Looper.loop(Looper.java:164)

        at android.app.ActivityThread.main(ActivityThread.java:6494)

        at java.lang.reflect.Method.invoke(Native Method)

        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)

        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'char[] java.lang.String.toCharArray()' on a null object reference

Anyone faced and solved it?

Upvotes: 0

Views: 628

Answers (1)

zhangxaochen
zhangxaochen

Reputation: 34047

Before running the demo, complete preparations in the README file:

  • Open this project by Android Studio.
  • Go to AppGallery Connect page to create your new application. Make sure your application's package name is com.huawei.agc.clouddb.xxxx.
  • Go to Auth tab and enable Huawei account authentication.
  • Go to Cloud Database tab and enable database service, and import the object type in CloudDBQuickStart_1.json under the root directory of project. Or you can create it with name BookInfo, and add all fields in BookInfo.java in the sample project.
  • Download agconnect-services.json from Generate view tab, and add it under app directory.
  • Add your key store to build script, see app/build.gradle. To generate an key store, you can use tool provided by Android Studio: Build -> Generate signed bundle and apk -> Choose apk selection, and then do as hints step by step. Then fill the password and alias name into app/build.gradle. Export the SHA256 fingerprints by keytool: keytool -list -v -keystore xxxx.jks and fill it into "SHA256 fingerprints" in Generate view tab.
  • Run the sample on Android device. Attention: Huawei mobile service(HMS) should have been installed on your devices already.

Upvotes: 1

Related Questions