一、集成HMS SDK 3.0报错AGConnectInitializeProvider
现象:
华为渠道接入使用的maven仓,兴冲冲配置完毕之后,一运行就crash了,真扫兴,查看logcat:
- E/AndroidRuntime: FATAL EXCEPTION: main
- Process: cn.xxx.xxx.huawei, PID: 22847
- java.lang.RuntimeException: Unable to get provider com.huawei.agconnect.core.provider.AGConnectInitializeProvider: java.security.InvalidParameterException: url is null
- at android.app.ActivityThread.installProvider(ActivityThread.java:6537)
- at android.app.ActivityThread.installContentProviders(ActivityThread.java:6025)
- at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5931)
- at android.app.ActivityThread.access$1200(ActivityThread.java:200)
- at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1673)
- at android.os.Handler.dispatchMessage(Handler.java:106)
- at android.os.Looper.loop(Looper.java:201)
- at android.app.ActivityThread.main(ActivityThread.java:6810)
- at java.lang.reflect.Method.invoke(Native Method)
- at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
- at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
- Caused by: java.security.InvalidParameterException: url is null
- at com.huawei.agconnect.common.b.c.a(Unknown Source:20)
- at com.huawei.agconnect.credential.CredentialServiceRegistrar.initialize(Unknown Source:6)
- at com.huawei.agconnect.core.impl.ServiceRegistrarParser.getServices(ServiceRegistrarParser.java:43)
- at com.huawei.agconnect.core.impl.AGConnectInstanceImpl.<init>(AGConnectInstanceImpl.java:18)
- at com.huawei.agconnect.AGConnectInstance.initialize(AGConnectInstance.java:21)
- at com.huawei.agconnect.core.provider.AGConnectInitializeProvider.onCreate(AGConnectInitializeProvider.java:18)
- at android.content.ContentProvider.attachInfo(ContentProvider.java:1927)
- at android.content.ContentProvider.attachInfo(ContentProvider.java:1902)
- at android.app.ActivityThread.installProvider(ActivityThread.java:6532)
- at android.app.ActivityThread.installContentProviders(ActivityThread.java:6025)
- at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5931)
- at android.app.ActivityThread.access$1200(ActivityThread.java:200)
- at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1673)
- at android.os.Handler.dispatchMessage(Handler.java:106)
- at android.os.Looper.loop(Looper.java:201)
- at android.app.ActivityThread.main(ActivityThread.java:6810)
- at java.lang.reflect.Method.invoke(Native Method)
- at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
- at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
分析:
这个报错是因为hms:hianalytics导致的,大部分用户一开始都没有在华为后台网站里配置analytics参数,所以hms:hianalytics初始化的时候就会报错崩溃。
解决方法:
第一种方法是:如果计划使用hms:hianalytics,则必须先去华为后台网站里配置analytics参数。
第二是方法是:如果不计划使用hms:hianalytics,就不进行hms:hianalytics初始化。
初始化的地方在Module的build.gradle中,删除implementation 'com.huawei.hms:hianalytics:5.0.0.301'这句就好了
- dependencies {
- implementation 'com.huawei.hms:base:4.0.4.301'
- implementation 'com.huawei.hms:hwid:4.0.4.300'
- implementation 'com.huawei.hms:iap:4.0.4.300'
- implementation 'com.huawei.hms:game:4.0.3.301'
- //implementation 'com.huawei.hms:hianalytics:5.0.0.301'
- }
继续阅读
评论