我有一个项目 A 作为库 jar 文件,其中包含一个 ContentProvider。然后我需要在项目 B 中使用它。正如 Manifest 中所声明的:
<provider
android:authorities="com.gezbox.android.onepiece"
android:exported="true"
android:name="com.gezbox.android.api.provider.GezboxProvider"/>
但是问题来了:
04-17 17:55:50.695: WARN/dalvikvm(5527): threadid=13: thread exiting with uncaught exception (group=0x40def300)
04-17 17:55:50.695: WARN/ActivityManager(258): Permission denied: checkComponentPermission() owningUid=10027
04-17 17:55:50.695: WARN/ActivityManager(258): Permission denied: checkComponentPermission() owningUid=10027
04-17 17:55:50.695: WARN/ActivityManager(258): Permission Denial: opening provider com.gezbox.android.api.provider.GezboxProvider from ProcessRecord{415d5e08 5527:com.gezbox.android.onepiece/u0a31} (pid=5527, uid=10031) that is not exported from uid 10027
04-17 17:55:50.711: ERROR/AndroidRuntime(5527): FATAL EXCEPTION: IntentService[GezboxService]
java.lang.SecurityException: Permission Denial: opening provider com.gezbox.android.api.provider.GezboxProvider from ProcessRecord{415d5e08 5527:com.gezbox.android.onepiece/u0a31} (pid=5527, uid=10031) that is not exported from uid 10027
at android.os.Parcel.readException(Parcel.java:1425)
at android.os.Parcel.readException(Parcel.java:1379)
at android.app.ActivityManagerProxy.getContentProvider(ActivityManagerNative.java:2354)
at android.app.ActivityThread.acquireProvider(ActivityThread.java:4219)
at android.app.ContextImpl$ApplicationContentResolver.acquireProvider(ContextImpl.java:1688)
at android.content.ContentResolver.acquireProvider(ContentResolver.java:1083)
at android.content.ContentResolver.acquireContentProviderClient(ContentResolver.java:1146)
at android.content.ContentResolver.applyBatch(ContentResolver.java:896)
at com.gezbox.android.api.processor.PostOrderProcessor.updateContentProvider(PostOrderProcessor.java:57)
at com.gezbox.android.api.processor.PostOrderProcessor.post_order(PostOrderProcessor.java:33)
at com.gezbox.android.api.GezboxService.onHandleIntent(GezboxService.java:196)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.os.HandlerThread.run(HandlerThread.java:60)