NoClassDefFoundError - Rejecting re-init on previously-failed class

[亡魂溺海] 提交于 2019-12-05 06:22:04

Happens for me only if instant run is enabled.

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.

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

you must add uses-library in your AndroidManifest.xml

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!