Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NoClassDefFoundError - Rejecting re-init on previously-failed class

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

like image 414
bartat Avatar asked Oct 02 '12 19:10

bartat


4 Answers

Happens for me only if instant run is enabled.

like image 156
Tobias Avatar answered Oct 16 '22 11:10

Tobias


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.

like image 28
Combuster Avatar answered Oct 16 '22 12:10

Combuster


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
like image 3
Pavel Synek Avatar answered Oct 16 '22 12:10

Pavel Synek


you must add uses-library in your AndroidManifest.xml

like image 2
laowen Avatar answered Oct 16 '22 11:10

laowen