Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NoClassDefFoundError: android.provider.Settings$Global #81

Open
ligi opened this issue Aug 30, 2018 · 8 comments
Open

java.lang.NoClassDefFoundError: android.provider.Settings$Global #81

ligi opened this issue Aug 30, 2018 · 8 comments

Comments

@ligi
Copy link

ligi commented Aug 30, 2018

test-butler 1.4.0 crashes on a emulator with SDK level 15 with:

I/ActivityManager( 1259): Start proc com.linkedin.android.testbutler for service com.linkedin.android.testbutler/.ButlerService: pid=1784 uid=1000 gids={1015, 3002, 3001, 3003}
E/AndroidRuntime( 1784): FATAL EXCEPTION: main
E/AndroidRuntime( 1784): java.lang.NoClassDefFoundError: android.provider.Settings$Global
E/AndroidRuntime( 1784):        at com.linkedin.android.testbutler.AlwaysFinishActivitiesChanger.getAlwaysFinishActivitiesState(AlwaysFinishActivitiesChanger.java:62)
E/AndroidRuntime( 1784):        at com.linkedin.android.testbutler.AlwaysFinishActivitiesChanger.saveAlwaysFinishActivitiesState(AlwaysFinishActivitiesChanger.java:39)
E/AndroidRuntime( 1784):        at com.linkedin.android.testbutler.ButlerService.onCreate(ButlerService.java:153)
E/AndroidRuntime( 1784):        at android.app.ActivityThread.handleCreateService(ActivityThread.java:2253)
E/AndroidRuntime( 1784):        at android.app.ActivityThread.access$1600(ActivityThread.java:123)
E/AndroidRuntime( 1784):        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1201)
E/AndroidRuntime( 1784):        at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 1784):        at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 1784):        at android.app.ActivityThread.main(ActivityThread.java:4424)
E/AndroidRuntime( 1784):        at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 1784):        at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 1784):        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime( 1784):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime( 1784):        at dalvik.system.NativeStart.main(Native Method)

@Kisty
Copy link
Contributor

Kisty commented Aug 30, 2018

Might need to either access through reflection or bump minSdkVersion to 17.

minSdkVersion = 14

@ligi
Copy link
Author

ligi commented Aug 30, 2018

please do not bump minSdkVersion to 17 - for me that would mean I need to stop using it.

@Kisty
Copy link
Contributor

Kisty commented Aug 30, 2018

I can see that there are two lines that would need to be accessed using reflection or an API check:

return Settings.Global.getInt(contentResolver, Settings.Global.ALWAYS_FINISH_ACTIVITIES) != 0;

return Settings.Global.putInt(contentResolver, Settings.Global.ALWAYS_FINISH_ACTIVITIES, value ? 1 : 0);

Can you see any others? I am surprised this didn't get flagged up in the lint check.

Need to replace the call for <17 with: https://developer.android.com/reference/android/provider/Settings.System.html#ALWAYS_FINISH_ACTIVITIES

@Kisty
Copy link
Contributor

Kisty commented Aug 30, 2018

@ligi would you be able to cook up a PR with an API check that calls the appropriate settings method: either Settings for API <17 and Settings.Global for API 17>=?

@ligi
Copy link
Author

ligi commented Aug 30, 2018

Yes I am able - but I won't have time for this the next 2 months at minimum. My workaround now is to use test-butler 1.3.2 which works for me. This was just introduced with 1.4.0 via 9aa710c - cc @kurtzmarc @drewhannay

@kurtzmarc
Copy link

Strange - this wasn't picked up in lint. I don't see a warning in AS. I'll whip up a fix.

kurtzmarc pushed a commit to kurtzmarc/test-butler that referenced this issue Aug 30, 2018
@Kisty
Copy link
Contributor

Kisty commented Aug 30, 2018

@kurtzmarc Ah, this is why!

@kurtzmarc
Copy link

Ah. That was C&P from another class. Really should be removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants