ClassNotFoundException on AndroidAnnotations generated classes since update to ADT 22

人走茶凉 提交于 2019-12-28 06:19:06

问题


This project worked wonders before updating to ADT22. I already lost a day because of not knowing I had to download build tools, and I'm afraid I'm going to loose another one because of this.

When I try to build the same code that was working two days ago, I get this exception:

com.cidaut.blueparking fatal error : Unable to instantiate activity \
    ComponentInfo{com.cidaut.blueparking/com.cidaut.blueparking.SplashScreen_}: \
    java.lang.ClassNotFoundException: \
    Didn't find class "com.cidaut.blueparking.SplashScreen_" on path: \
    /data/app/com.cidaut.blueparking-1.apk
java.lang.RuntimeException: Unable to instantiate activity \
    ComponentInfo{com.cidaut.blueparking/com.cidaut.blueparking.SplashScreen_}: \
    java.lang.ClassNotFoundException: \
    Didn't find class "com.cidaut.blueparking.SplashScreen_" on path: \
    /data/app/com.cidaut.blueparking-1.apk

  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
  at android.app.ActivityThread.access$600(ActivityThread.java:141)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loop(Looper.java:137)
  at android.app.ActivityThread.main(ActivityThread.java:5041)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:511)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
  at dalvik.system.NativeStart.main(Native Method)

Caused by: java.lang.ClassNotFoundException: \
    Didn't find class "com.cidaut.blueparking.SplashScreen_" on path: \
    /data/app/com.cidaut.blueparking-1.apk
  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
  at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
  ... 11 more

I actually find it weird that it is trying to find the class on the APK file, but whatever. Is there any solution to this?

By the way, my classpath includes the source folder where AndroidAnnotations generates the code, so that's not the issue.

Here's my Order and Export window

AndroidAnnotations class generation error log

EDIT: Now it is working

The procedure I followed was this:

  1. Clean and rebuild everything
  2. Check everything on the Order and Export tab of every project (both the main project and the libraries)
  3. Clean and rebuild everything again

It works now. I can't believe I have lost almost 12 hours because of this...


回答1:


Go to the "Order And Export" tab of "Configure Build Path" and click the check mark next to all of your required libraries




回答2:


Here is the solution :

  1. In Eclipse, right click on the Project name and choose Properties

  2. Select Order and Export tab, then make sure that the Android Private Libraries is checked

  3. Clean your project, from Project -> Clean

This should work




回答3:


I had the same issue and for me it was due to the "Allow output folder for source folder" option in the project "java build path". I unchecked it, and checked it again and the problem was gone. For whatever reason the path used was different to the default one. Maybe it is due to m2e android.




回答4:


I'd had a similar problem - turned out that there was a JAR mismatch of the support library included in a references project which was causing the problem. Making sure that each project was using the same version of the support library fixed it for me.




回答5:


Popping in here with an answer in case someone is having this issue in the future. I added ActionBarCompat to my app which was using AndroidAnnotations and was having this same issue. It turns out that all of the libraries which are being used by a particular application need to live within the parent app. So, even though ABC was a library project within Eclipse and the code compiled, I still needed to include ABC as a library within my application.



来源:https://stackoverflow.com/questions/16603002/classnotfoundexception-on-androidannotations-generated-classes-since-update-to-a

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