GCX-HCI / tray

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

Why the value cannot be saved on some devices? #108

Closed jinfatimay closed 7 years ago

jinfatimay commented 7 years ago

As the title, some user gave me feedback that their value cannot be saved. (e.g., nubia z11)

StefMa commented 7 years ago

What do you mean with "users"? You are a developer of an app, right? Or do you provide an sdk with tray for others? 🤔

Whatever. Can you please specify whats going wrong exactly? For example showing your code how do you store the data...

Have you upgraded to the latest version (0.12.0)? Please check the release page for (maybe) breaking changes...

Sent from my LGE Nexus 5X using FastHub

jinfatimay commented 7 years ago

The users are who download my app on app store. And Yes, I'm a developer of an app. At first, If I use 0.12.0 with the following configuration and implement, there are some ANR issue on some devices. In Manifest file :

<provider
       android:name="net.grandcentrix.tray.provider.TrayContentProvider"
       android:authorities="my.packagename.tray"
       android:exported="false"
       tools:replace="android:authorities" />

In module class :

public class TrayA extends TrayPreferences {
    public void setSomeValue(Value value) {
        put(Key, value);
    }
}

And my Tray pool class :

public class TrayPool{
    private static final TrayA trayA = new TrayA(applicationContext);
    private static final TrayB trayB = new TrayB(applicationContext);

When I want to save some value in some tray object, I call method like that

TrayPool.getTrayA().setSomeValue(value)

However, I get some ANR reports on google play console :

  at net.grandcentrix.tray.provider.TrayProviderHelper.a (TrayProviderHelper.java:185)
  at net.grandcentrix.tray.provider.ContentProviderStorage.a (ContentProviderStorage.java:216)
  at net.grandcentrix.tray.core.Preferences.l (Preferences.java:258)
- locked <0x029cdaa3> (a TrayA)
  at net.grandcentrix.tray.core.Preferences.H (Preferences.java:292)
  at net.grandcentrix.tray.core.Preferences.n (Preferences.java:175)
  at TrayA.a (TrayA.java:281)
  at net.grandcentrix.tray.core.Preferences.l (Preferences.java:269)
- locked <0x029cdaa3> (a TrayA)
  at net.grandcentrix.tray.core.Preferences.H (Preferences.java:292)
  at net.grandcentrix.tray.core.Preferences.n (Preferences.java:175)
  at TrayA.a (TrayA.java:281)
  at net.grandcentrix.tray.core.Preferences.l (Preferences.java:269)

And If I downgrade the Tray version to 0.11.0 and change back the authority string like

resValue "string", "tray__authority", "${applicationId}.tray"

in the gradle file, the ARN issue is fixed(maybe) but some devices cannot save its value.

How could I fix this issue? Thanks for your attention. If you need any other information, please let me know.

p.s., Sorry for my poor English. I'm not a native speaker.

jinfatimay commented 7 years ago

Hi, I guess that it maybe the issue of the "proguard". (It only happens when I use the "proguard") Could you please help me to solve this problem? Thanks for your help.

passsy commented 7 years ago

What confuses me is your usage of static. Try to lazy initialize the your Tray module at first access. This should solve the problem.

StefMa commented 7 years ago

@jinfatimay had that helped? Or still issues? 🤔