java.lang.SecurityException: Permission Denial: opening provider

在测试调用外部提供的ContentProvider时候报一下错误:


java.lang.SecurityException: Permission Denial: opening provider com.example.onehw.BookProvider from ProcessRecord{b2f1b230 8449:com.example.adtest/u0a53} (pid=8449, uid=10053) that is not exported from uid 10052
at android.os.Parcel.readException(Parcel.java:1465)
at android.os.Parcel.readException(Parcel.java:1419)
at android.app.ActivityManagerProxy.getContentProvider(ActivityManagerNative.java:2848)
at android.app.ActivityThread.acquireProvider(ActivityThread.java:4415)
at android.app.ContextImpl$ApplicationContentResolver.acquireProvider(ContextImpl.java:2192)
at android.content.ContentResolver.acquireProvider(ContentResolver.java:1378)
at android.content.ContentResolver.insert(ContentResolver.java:1184)
at com.example.adtest.ProverderTest.testInsert(ProverderTest.java:16)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1701)


是权限的问题,在AndroidManifest.xml 加上红色部分就解决


<provider android:name="BookProvider" android:authorities="com.example.provides.bookprovider" android:exported="true" />















你可能感兴趣的:(java.lang.SecurityException: Permission Denial: opening provider)