GCX-HCI / tray

a SharedPreferences replacement for Android with multiprocess support
Apache License 2.0
2.29k stars 273 forks source link

RunTimeException: Unable to create application caused by TrayContract.getAuthority #129

Open OUCHUNYU opened 6 years ago

OUCHUNYU commented 6 years ago

tray Version (E.g. 0.12.0)

0.12.0

Device(s) (E.g. Samsung Galaxy S8)

unknown, likely many different device manufactures and types

How have you setup tray (E.g. Initialized in Application.onCreate, in an Activity, BroadcastReceiver, IntentService, MainThread)

In my case, I use Tray in a library project. The library splits into client and service. The client part of the library is used in application main process. The service part is a remote service running in a separate process. Both client and service initialize tray AppPreferences object and do read/write operations.

Both client and server side share use Tray in the same way. initialize it this way

private AppPreferences appPreferences = new AppPreferences(context);

and call put and get

Android Version (E.g. Marshmallow or better API 23)

Around version 4.2 to 4.4

Stacktrace

Stacktrace ``` Fatal Exception: java.lang.RuntimeException: Unable to create application xxxxxxxx: xxxxx: Internal tray error. Could not find the provider authority. Please fill an issue at https://github.com/grandcentrix/tray/issues at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6431) at android.app.ActivityThread.access$1800(ActivityThread.java:229) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1887) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:7331) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) Caused by net.grandcentrix.tray.a.h: Internal tray error. Could not find the provider authority. Please fill an issue at https://github.com/grandcentrix/tray/issues at net.grandcentrix.tray.provider.TrayContract.getAuthority(TrayContract.java:138) at net.grandcentrix.tray.provider.TrayContract.generateContentUri(TrayContract.java:109) at net.grandcentrix.tray.provider.TrayContract.generateContentUri(TrayContract.java:80) at net.grandcentrix.tray.provider.TrayUri.(TrayUri.java:75) at net.grandcentrix.tray.provider.ContentProviderStorage.(ContentProviderStorage.java:146) at net.grandcentrix.tray.TrayPreferences.(TrayPreferences.java:43) at net.grandcentrix.tray.TrayPreferences.(TrayPreferences.java:48) at net.grandcentrix.tray.AppPreferences.(AppPreferences.java:41) ```

Description (Just a place with additional information, more == better)

passsy commented 6 years ago

Are you accessing Tray in Application#onCreate?

OUCHUNYU commented 6 years ago

@passsy Thanks for the reply. My project is a library project. Inside this library, I access Tray in the library constructor, but I don't really know how the library users construct my library, I would imagine there is a high chance that a user constructs my library in his/her Apllication#onCreate(), when this happens, we are accessing Tray directly in Apllication#onCreate().

OUCHUNYU commented 6 years ago

@passsy Is there something I can do on my end to fix the issue?

jr-developer200 commented 4 years ago

@OUCHUNYU Could you please update the library to fix this issue? So that we can access Tray in Application#onCreate. Thanks!