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

Android Samsung devices crash on init #33

Closed
maxchursin opened this issue Jan 23, 2016 · 8 comments
Closed

Android Samsung devices crash on init #33

maxchursin opened this issue Jan 23, 2016 · 8 comments
Labels
Milestone

Comments

@maxchursin
Copy link

On Android 5.0 (so far) 100% samsung.
Crash happens every time I try to init Cache like so:

CacheBuilder.newCache(Long.class, BasePresenter.class)
.maxSize(maxSize)
.expiryDuration(expirationValue, expirationUnit)
.build();

01-22 11:33:28.474: E/AndroidRuntime(11647): java.lang.LinkageError: Error instantiating org.cache2k.spi.Cache2kCoreProvider, got java.io.IOException: Class resource file not found: org/cache2k/services/org.cache2k.spi.Cache2kCoreProvider
01-22 11:33:28.474: E/AndroidRuntime(11647): at org.cache2k.spi.SingleProviderResolver.loadProvider(SingleProviderResolver.java:101)
01-22 11:33:28.474: E/AndroidRuntime(11647): at org.cache2k.spi.SingleProviderResolver.resolve(SingleProviderResolver.java:86)
01-22 11:33:28.474: E/AndroidRuntime(11647): at org.cache2k.CacheBuilder.(CacheBuilder.java:41)
01-22 11:33:28.474: E/AndroidRuntime(11647): at com.remind101.PresenterManager.(PresenterManager.java:24)
01-22 11:33:28.474: E/AndroidRuntime(11647): at com.remind101.PresenterManager.getInstance(PresenterManager.java:32)
01-22 11:33:28.474: E/AndroidRuntime(11647): at com.remind101.ui.fragments.BaseMvpFragment.onSaveInstanceState(BaseMvpFragment.java:48)
01-22 11:33:28.474: E/AndroidRuntime(11647): at android.support.v4.app.Fragment.performSaveInstanceState(Fragment.java:2109)
01-22 11:33:28.474: E/AndroidRuntime(11647): at android.support.v4.app.FragmentManagerImpl.saveFragmentBasicState(FragmentManager.java:1767)
01-22 11:33:28.474: E/AndroidRuntime(11647): at android.support.v4.app.FragmentManagerImpl.saveAllState(FragmentManager.java:1835)
01-22 11:33:28.474: E/AndroidRuntime(11647): at android.support.v4.app.FragmentController.saveAllState(FragmentController.java:125)
01-22 11:33:28.474: E/AndroidRuntime(11647): at android.support.v4.app.FragmentActivity.onSaveInstanceState(FragmentActivity.java:523)
01-22 11:33:28.474: E/AndroidRuntime(11647): at com.remind101.ui.activities.ClassFeedActivity.onSaveInstanceState(ClassFeedActivity.java:304)
01-22 11:33:28.474: E/AndroidRuntime(11647): at android.app.Activity.performSaveInstanceState(Activity.java:1383)
01-22 11:33:28.474: E/AndroidRuntime(11647): at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1286)
01-22 11:33:28.474: E/AndroidRuntime(11647): at android.app.ActivityThread.callCallActivityOnSaveInstanceState(ActivityThread.java:4475)
01-22 11:33:28.474: E/AndroidRuntime(11647): at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3847)
01-22 11:33:28.474: E/AndroidRuntime(11647): at android.app.ActivityThread.handleStopActivity(ActivityThread.java:3910)
01-22 11:33:28.474: E/AndroidRuntime(11647): at android.app.ActivityThread.access$1200(ActivityThread.java:178)
01-22 11:33:28.474: E/AndroidRuntime(11647): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1473)
01-22 11:33:28.474: E/AndroidRuntime(11647): at android.os.Handler.dispatchMessage(Handler.java:102)
01-22 11:33:28.474: E/AndroidRuntime(11647): at android.os.Looper.loop(Looper.java:145)
01-22 11:33:28.474: E/AndroidRuntime(11647): at android.app.ActivityThread.main(ActivityThread.java:5944)
01-22 11:33:28.474: E/AndroidRuntime(11647): at java.lang.reflect.Method.invoke(Native Method)
01-22 11:33:28.474: E/AndroidRuntime(11647): at java.lang.reflect.Method.invoke(Method.java:372)
01-22 11:33:28.474: E/AndroidRuntime(11647): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
01-22 11:33:28.474: E/AndroidRuntime(11647): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)

@cruftex
Copy link
Member

cruftex commented Jan 23, 2016

There is a test with android before each release now, to prevent this.

Are you sure you have added the cache2k-api and cache2k-core jar to your application?
It looks like the cache2k-core jar is missing at runtime.

@maxchursin
Copy link
Author

I run the same exact build on my emulators and Nexus 5X and it works with no problem. However our crashlytics reports shows a spike for crashes with this stacktrace. Samsung Galaxy S6 running Android 5.0.1/2 are problematic so far

@maxchursin
Copy link
Author

oh, and yes, i have both:
compile 'org.cache2k:cache2k-core:0.21.1'
compile 'org.cache2k:cache2k-api:0.21.1'

@cruftex
Copy link
Member

cruftex commented Jan 23, 2016

I tracked down a possible source of the problem.

Please try to do:

Thread.currentThread().setContextClassLoader(getClass().getClassLoader())

Before doing anything with the cache. Here is some background on this:

http://stackoverflow.com/questions/13407006/android-class-loader-may-fail-for-processes-that-host-multiple-applications

My apologies for the bad experience!

Please report back whether this solves the problem. I will do a fix for the next release, so this is not needed any more.

@maxchursin
Copy link
Author

seems like it has been fixed with this, thanks for a quick response. It's Samsung, they always causing fragmentation issues, sorry.

@cruftex cruftex added this to the v0.23 milestone Jan 25, 2016
@cruftex
Copy link
Member

cruftex commented Jan 25, 2016

Perfect, you are welcome!

Keeping the issue open, to remind me to do a change in the next release, so this workaround is not needed.

@cruftex cruftex added the bug label Jan 25, 2016
@maxchursin
Copy link
Author

👍

@cruftex
Copy link
Member

cruftex commented Feb 10, 2016

Fixed in 0.23

@cruftex cruftex closed this as completed Feb 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants