9

Please somebody explain me what this error means and how to avoid it.

After a while my app Force Closes because of this error:

09-28 12:53:45.746 I/dalvikvm(29489): Rejecting re-init on previously-failed class Lcom/bartat/android/ui/task/AsyncTaskExt; v=0x0
09-28 12:53:45.748 D/AndroidRuntime(29489): Shutting down VM
09-28 12:53:45.755 I/am_crash( 1146): [29489,com.bartat.android.secret,572996,java.lang.NoClassDefFoundError,com.bartat.android.ui.task.AsyncTaskExt,CommandsActivity.java,726]
09-28 12:53:45.755 I/am_finish_activity( 1146): [1079225264,123,com.bartat.android.secret/.CommandsActivity,crashed]
09-28 12:53:45.750 W/dalvikvm(29489): threadid=1: thread exiting with uncaught exception (group=0x40015560)
09-28 12:53:45.752 E/AndroidRuntime(29489): FATAL EXCEPTION: main
09-28 12:53:45.752 E/AndroidRuntime(29489): java.lang.NoClassDefFoundError: com.bartat.android.ui.task.AsyncTaskExt

This problem couldn't be solved by reinstalling the app.

If I rename the AsyncTaskExt to AsyncTaskExt2 for example then it works again for long. But after a few weeks/months it started to get this error again.

What does it mean? Why it is thrown and how to avoid it without renaming the class?

Please help me, Tamás

5 Answers 5

12

Happens for me only if instant run is enabled.

3
  • Thank a lot. Its working when i disable insta run. Still some issues with insta run?
    – Raj
    Commented Aug 30, 2017 at 12:25
  • Where is this "instant run" enable/disable located on Android Studio 2022.1.1?
    – WebViewer
    Commented Feb 21, 2023 at 9:19
  • Seems like instant run is no more: android-developers.googleblog.com/2019/08/…
    – Tobias
    Commented Feb 28, 2023 at 7:39
11

This happens when a class couldn't be loaded for a variety of reasons. Unfortunately the new ART runtime doesn't log sufficient information as to the cause of this. If you can get hold of an older android device with Dalvik you'll see different logging, usually revealing the offence with more precision.

Last time I saw it live I had to deal with a JAR file that didn't actually include or list its dependencies, so adding the right dependent library to the gradle file solved it. The biggest issue is to figure which classes went missing - something dalvik logs/decompilation/documentation might be able to tell you.

There are many other reasons why classes can't be loaded in the entirety of the Java language so this specific cause might not apply universally.

3
  • This helped me a lot. Adding a dependency JAR solved the problem.
    – Rediska
    Commented Apr 8, 2016 at 23:27
  • Adding a missing JAR dependency fixed this for me too. Thanks!
    – pdsouza
    Commented Feb 9, 2017 at 6:46
  • "for a variety of reasons" includes Chrome version mismatch with the Android OS version: stackoverflow.com/a/70867926/2597758
    – WebViewer
    Commented Feb 21, 2023 at 9:25
3

I started having this problem after building another project with New Relic analytics enabled. Gradle daemon then cached the New Relic agent and it couldn't launch the other app.

What helped was

./gradlew --stop
2

you must add uses-library in your AndroidManifest.xml

1
  • 4
    Can you please expound on this answer please?
    – nww04
    Commented Oct 23, 2018 at 1:48
0

Are you sure is this the first exception you are getting after running your application? There may be some uncaught exceptions previously.

1
  • I don't know what cause this error, I mean are there any errors before it happens or not. But when this exception occurs there are no other errors in the log. I guess the system (vm?) stored somewhere that there was a problem with this class. But I haven't catched the first occurance yet.
    – bartat
    Commented Oct 3, 2012 at 6:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.