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

Crash with ART runtime on Android Lollipop #20

Closed
zhanghai opened this issue Nov 17, 2014 · 6 comments
Closed

Crash with ART runtime on Android Lollipop #20

zhanghai opened this issue Nov 17, 2014 · 6 comments

Comments

@zhanghai
Copy link

What went wrong:

ART runtime fails to load the SimpleDateTimeTextProvider class when DateTimeFormatBuilder is referenced on Android Lollipop. The app crashes immediately.

Note that the library jar is fetched from the maven central repository.

Steps to reproduce:

1.Create a new Project in Android Studio

  1. Add compile 'org.threeten:threetenbp:1.1' to the dependencies section in app.gradle
  2. Add DateTimeFormatter test = DateTimeFormatter.ofPattern("HH:mm"); to MainActivity.onCreate().
  3. Run the app in emulator running Android Lollipop, and the app crashes.

Stacktrace from my emulator:

I/ActivityManager( 1297): Start proc com.example.yourapplication for activity com.example.yourapplication/.MainActivity: pid=2012 uid=10053 gids={50053, 9997} abi=x86_64
E/art     ( 2012): Failed writing handshake bytes (-1 of 14): Broken pipe
I/art     ( 2012): Debugger is no longer active
I/art     ( 2012): Rejecting re-init on previously-failed class java.lang.Class<org.threeten.bp.format.DateTimeTextProvider>
I/art     ( 2012): Rejecting re-init on previously-failed class java.lang.Class<org.threeten.bp.format.DateTimeTextProvider>
I/art     ( 2012): Rejecting re-init on previously-failed class java.lang.Class<org.threeten.bp.format.DateTimeFormatterBuilder$2>
I/art     ( 2012): Rejecting re-init on previously-failed class java.lang.Class<org.threeten.bp.format.DateTimeFormatterBuilder$2>
I/art     ( 2012): Rejecting re-init on previously-failed class java.lang.Class<org.threeten.bp.format.DateTimeTextProvider>
I/art     ( 2012): Rejecting re-init on previously-failed class java.lang.Class<org.threeten.bp.format.DateTimeTextProvider>
I/art     ( 2012): Rejecting re-init on previously-failed class java.lang.Class<org.threeten.bp.format.SimpleDateTimeTextProvider>
I/art     ( 2012): Rejecting re-init on previously-failed class java.lang.Class<org.threeten.bp.format.SimpleDateTimeTextProvider>
D/AndroidRuntime( 2012): Shutting down VM
--------- beginning of crash
E/AndroidRuntime( 2012): FATAL EXCEPTION: main
E/AndroidRuntime( 2012): Process: com.example.yourapplication, PID: 2012
E/AndroidRuntime( 2012): java.lang.NoClassDefFoundError: Failed resolution of: Lorg/threeten/bp/format/SimpleDateTimeTextProvider;
E/AndroidRuntime( 2012):    at org.threeten.bp.format.SimpleDateTimeTextProvider$LocaleStore.<init>(SimpleDateTimeTextProvider.java:333)
E/AndroidRuntime( 2012):    at org.threeten.bp.format.DateTimeFormatterBuilder.appendText(DateTimeFormatterBuilder.java:726)
E/AndroidRuntime( 2012):    at org.threeten.bp.format.DateTimeFormatter.<clinit>(DateTimeFormatter.java:608)
E/AndroidRuntime( 2012):    at com.example.yourapplication.MainActivity.onCreate(MainActivity.java:19)
E/AndroidRuntime( 2012):    at android.app.Activity.performCreate(Activity.java:5933)
E/AndroidRuntime( 2012):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
E/AndroidRuntime( 2012):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
E/AndroidRuntime( 2012):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
E/AndroidRuntime( 2012):    at android.app.ActivityThread.access$800(ActivityThread.java:144)
E/AndroidRuntime( 2012):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
E/AndroidRuntime( 2012):    at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime( 2012):    at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime( 2012):    at android.app.ActivityThread.main(ActivityThread.java:5221)
E/AndroidRuntime( 2012):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 2012):    at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime( 2012):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
E/AndroidRuntime( 2012):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
E/AndroidRuntime( 2012): Caused by: java.lang.ClassNotFoundException: Didn't find class "org.threeten.bp.format.SimpleDateTimeTextProvider" on path: DexPathList[[zip file "/data/app/com.example.yourapplication-1/base.apk"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]
E/AndroidRuntime( 2012):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
E/AndroidRuntime( 2012):    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
E/AndroidRuntime( 2012):    at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
E/AndroidRuntime( 2012):    ... 17 more
E/AndroidRuntime( 2012):    Suppressed: java.lang.NoClassDefFoundError: org.threeten.bp.format.SimpleDateTimeTextProvider
E/AndroidRuntime( 2012):        at dalvik.system.DexFile.defineClassNative(Native Method)
E/AndroidRuntime( 2012):        at dalvik.system.DexFile.defineClass(DexFile.java:222)
E/AndroidRuntime( 2012):        at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:215)
E/AndroidRuntime( 2012):        at dalvik.system.DexPathList.findClass(DexPathList.java:321)
E/AndroidRuntime( 2012):        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
E/AndroidRuntime( 2012):        ... 19 more
E/AndroidRuntime( 2012):    Suppressed: java.lang.ClassNotFoundException: org.threeten.bp.format.SimpleDateTimeTextProvider
E/AndroidRuntime( 2012):        at java.lang.Class.classForName(Native Method)
E/AndroidRuntime( 2012):        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
E/AndroidRuntime( 2012):        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
E/AndroidRuntime( 2012):        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
E/AndroidRuntime( 2012):        ... 18 more
E/AndroidRuntime( 2012):    Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
W/ActivityManager( 1297):   Force finishing activity com.example.yourapplication/.MainActivity
@gregorko
Copy link

We run into the same issue on Lollipop.

@jodastephen
Copy link
Member

Someone needs to open a pull request with a proposed fix to progress this.

@zhanghai
Copy link
Author

zhanghai commented Dec 1, 2014

I'm not sure whether this is a coding issue or a packaging issue, @gregorko have you tried building this library yourself with Android Studio? If not, I may try it some time later.

@gregorko
Copy link

gregorko commented Dec 1, 2014

No I have not tried to build it yet. I used the maven distribution.

@zhanghai
Copy link
Author

zhanghai commented Dec 6, 2014

Worked out this problem.

This is caused by Android's missing java.util.spi.LocaleServiceProvider. In dalvik they ignored this missing class and things happend to be fine. In ART they refused to load the two classes extending this missing class so application crashed.

I did a fork for usage in my app, adding the missing class to org.threeten.bp package. (Adding to java.util.spi resulted in a scaring warning during compilation, so I gave it up.) Then things worked normally on Lollipop.

@gregorko You can refer to my fork. If you are using android studio, simply import the project as maven project and add a jar artifact in the project structure settings. Click build and you'll have the jar. You can also use my release.

@jodastephen I did not make a pull request, because I think you won't accept it due to the a bit hacky workaround, although it is the best I can do in production environment.

@jodastephen
Copy link
Member

Fixed by #22

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

No branches or pull requests

3 participants