找不到用户0的提供者null;预期会为此授权机构的Android Oreo找到有效的ContentProvider

时间:2018-10-01 09:23:02

标签: android android-contentprovider

我面临两个相互关联的问题, 我在Android Oreo设备中面临以下问题,

     java.lang.RuntimeException: Error receiving broadcast Intent { act=com.example.bluetooth.le.ACTION_REMOTE_RSSI_UPDATED flg=0x10 (has extras) } in com.linka.linkaapikit.module.widget.LockGattUpdateReceiver$1@762cfd9
    at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$-android_app_LoadedApk$ReceiverDispatcher$Args_52197(LoadedApk.java:1315)
    at android.app.-$Lambda$aS31cHIhRx41653CMnd4gZqshIQ.$m$7(Unknown Source:4)
    at android.app.-$Lambda$aS31cHIhRx41653CMnd4gZqshIQ.run(Unknown Source:39)
    at android.os.Handler.handleCallback(Handler.java:790)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:172)
    at android.app.ActivityThread.main(ActivityThread.java:6590)
    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.SecurityException: Failed to find provider null for user 0; expected to find a valid ContentProvider for this authority
    at android.os.Parcel.readException(Parcel.java:2005)
    at android.os.Parcel.readException(Parcel.java:1951)
    at android.content.IContentService$Stub$Proxy.notifyChange(IContentService.java:801)
    at android.content.ContentResolver.notifyChange(ContentResolver.java:2049)
    at android.content.ContentResolver.notifyChange(ContentResolver.java:2000)
    at android.content.ContentResolver.notifyChange(ContentResolver.java:1970)
    at com.activeandroid.Model.save(Model.java:162)

之后,我找到了以下解决方案,

添加到Android清单

 <provider
        android:name="com.activeandroid.content.ContentProvider"
        android:authorities="com.myapp"
        android:enabled="true"
        android:exported="false"
        />

但是在添加这一行之后,我又遇到了另一个问题,

 java.lang.IncompatibleClassChangeError: Superclass org.apache.http.params.BasicHttpParams of org.apache.http.params.SyncBasicHttpParams is declared final (declaration of 'org.apache.http.params.SyncBasicHttpParams' appears in /data/app/com.kolonishare-6KsxqUHOK_Q45cGI0D0bHg==/base.apk:classes16.dex)
    at java.lang.Class.classForName(Native Method)
    at java.lang.Class.forName(Class.java:453)
    at com.activeandroid.ModelInfo.scanForModelClasses(ModelInfo.java:187)
    at com.activeandroid.ModelInfo.scanForModel(ModelInfo.java:152)
    at com.activeandroid.ModelInfo.<init>(ModelInfo.java:63)
    at com.activeandroid.Cache.initialize(Cache.java:66)
    at com.activeandroid.ActiveAndroid.initialize(ActiveAndroid.java:44)
    at com.activeandroid.ActiveAndroid.initialize(ActiveAndroid.java:34)
    at com.activeandroid.content.ContentProvider.onCreate(ContentProvider.java:39)
    at android.content.ContentProvider.attachInfo(ContentProvider.java:1919)
    at android.content.ContentProvider.attachInfo(ContentProvider.java:1894)
    at android.app.ActivityThread.installProvider(ActivityThread.java:6285)
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:5851)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5772)
    at android.app.ActivityThread.-wrap1(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661)
    at android.os.Handler.dispatchMessage(Handler.java:105)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6541)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

我清理并重建项目,使重新启动无效,但出现相同的错误。

1 个答案:

答案 0 :(得分:0)

您需要将xml放在其中

<provider android:name="com.activeandroid.content.ContentProvider"
    android:authorities="${applicationId}.fileprovider"
    android:enabled="true"
    android:exported="false" />