10

I have the following problem. We have created a Game Center Application that provides a framework to create ad hoc wifi games and manages the highscores / encounters of such games.

Database access for highscores is done with a provider:

<provider     
    android:name="com.identifier.gamecenterapp.contentprovider.MyGamesContentProvider"
    android:authorities="com.identifier.gamecenterapp.contentprovider" >
</provider>

our demo game (as reference for future game developers) contains the following permissions:

<uses-permission android:name="com.identifier.gamecenterapp.contentprovider.READ_DATABASE"/>
<uses-permission android:name="com.identifier.gamecenterapp.contentprovider.WRITE_DATABASE"/>

Now - whenever we try to access the provider with the game, we get the following error:

09-17 12:15:52.221: E/AndroidRuntime(4551): FATAL EXCEPTION: main
09-17 12:15:52.221: E/AndroidRuntime(4551): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.identifier.gamecenter.gctictactoe/com.identifier.gamecenter.game.MainActivity}: java.lang.SecurityException: Permission Denial: opening provider com.identifier.gamecenterapp.contentprovider.MyGamesContentProvider from ProcessRecord{42622078 4551:com.identifier.gamecenter.gctictactoe/u0a10108} (pid=4551, uid=10108) that is not exported from uid 10072
09-17 12:15:52.221: E/AndroidRuntime(4551):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
09-17 12:15:52.221: E/AndroidRuntime(4551):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
09-17 12:15:52.221: E/AndroidRuntime(4551):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
09-17 12:15:52.221: E/AndroidRuntime(4551):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
09-17 12:15:52.221: E/AndroidRuntime(4551):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-17 12:15:52.221: E/AndroidRuntime(4551):     at android.os.Looper.loop(Looper.java:137)
09-17 12:15:52.221: E/AndroidRuntime(4551):     at android.app.ActivityThread.main(ActivityThread.java:5103)
09-17 12:15:52.221: E/AndroidRuntime(4551):     at java.lang.reflect.Method.invokeNative(Native Method)
09-17 12:15:52.221: E/AndroidRuntime(4551):     at java.lang.reflect.Method.invoke(Method.java:525)
09-17 12:15:52.221: E/AndroidRuntime(4551):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
09-17 12:15:52.221: E/AndroidRuntime(4551):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-17 12:15:52.221: E/AndroidRuntime(4551):     at dalvik.system.NativeStart.main(Native Method)
09-17 12:15:52.221: E/AndroidRuntime(4551): Caused by: java.lang.SecurityException: Permission Denial: opening provider c.identifier.gamecenterapp.contentprovider.MyGamesContentProvider from ProcessRecord{42622078 4551:com.identifier.gamecenter.gctictactoe/u0a10108} (pid=4551, uid=10108) that is not exported from uid 10072
09-17 12:15:52.221: E/AndroidRuntime(4551):     at android.os.Parcel.readException(Parcel.java:1431)
09-17 12:15:52.221: E/AndroidRuntime(4551):     at android.os.Parcel.readException(Parcel.java:1385)
09-17 12:15:52.221: E/AndroidRuntime(4551):     at android.app.ActivityManagerProxy.getContentProvider(ActivityManagerNative.java:2611)
09-17 12:15:52.221: E/AndroidRuntime(4551):     at android.app.ActivityThread.acquireProvider(ActivityThread.java:4515)
09-17 12:15:52.221: E/AndroidRuntime(4551):     at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:2036)
09-17 12:15:52.221: E/AndroidRuntime(4551):     at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:1149)
09-17 12:15:52.221: E/AndroidRuntime(4551):     at android.content.ContentResolver.query(ContentResolver.java:398)
09-17 12:15:52.221: E/AndroidRuntime(4551):     at android.content.ContentResolver.query(ContentResolver.java:357)
09-17 12:15:52.221: E/AndroidRuntime(4551):     at ch.ethz.csg.wlanopp.gapi.GameCenterController.getIdByGameTitle(GameCenterController.java:602)
09-17 12:15:52.221: E/AndroidRuntime(4551):     at ch.ethz.csg.wlanopp.gapi.GameCenterController.isRegistered(GameCenterController.java:343)
09-17 12:15:52.221: E/AndroidRuntime(4551):     at ch.ethz.csg.wlanopp.gapi.GameCenterController.addGame(GameCenterController.java:352)
09-17 12:15:52.221: E/AndroidRuntime(4551):     at ch.ethz.csg.gamecenter.gctictactoe.MainActivity.onCreate(MainActivity.java:130)
09-17 12:15:52.221: E/AndroidRuntime(4551):     at android.app.Activity.performCreate(Activity.java:5133)
09-17 12:15:52.221: E/AndroidRuntime(4551):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
09-17 12:15:52.221: E/AndroidRuntime(4551):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
09-17 12:15:52.221: E/AndroidRuntime(4551):     ... 11 more
09-17 12:20:52.487: I/Process(4551): Sending signal. PID: 4551 SIG: 9

The strange thing is, that it worked for quite a while. The error only throws on Android 4.3, previous versions (we tested 4.1 for example) did not have this issue.

Thank you for any insights how this might be resolved.

Sebastian Flückiger
  • 5,525
  • 8
  • 33
  • 69

1 Answers1

40

Below Android 4.3 the default value of "exported" of your provider is set to true. In Android 4.3 it is set to false.

<provider     
android:name="com.identifier.gamecenterapp.contentprovider.MyGamesContentProvider"
android:authorities="com.identifier.gamecenterapp.contentprovider"       
android:exported="true">
</provider>

And it will work.

Christophe Smet
  • 850
  • 10
  • 11
  • 1
    Google's "Crashes & ANR's" doesn't show (at least I don't see it) the Android versions with each crash report. How do you find out the Android version that the app crashed on ? – Someone Somewhere Dec 02 '13 at 22:58
  • @SomeoneSomewhere You can see them when you click on a particular crash or error in the "Crashes & ANR's" console.It will be under the tab named StackTraces. – Ahmed Faisal Oct 06 '14 at 18:56
  • By using exported = "true", its says - Exported content providers can provide access to potentially sensitive data. Any Idea to resolve this? – chiru Feb 12 '15 at 16:18
  • 3
    This is not valid anymore. Currently provider is checking if exporter is true or not. if its so it will throw an exception! – Ayyappa Jun 06 '15 at 22:41
  • 2
    Thx. You save my day! – DysaniazzZ Sep 19 '16 at 10:02
  • 7
    This is not valid anymore! `SecurityException: Provider must not be exported` – Chad Bingham Jul 15 '17 at 18:27