ClassNotFoundException on AndroidAnnotations generated classes since update to ADT 22
Asked Answered
P

5

14

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

Eclipse / Order and Export

AndroidAnnotations class generation error log

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...

Peipus answered 17/5, 2013 at 6:42 Comment(10)
Check if the classes exist, also check if builders are present and in the right order.Jokjakarta
The classes DO exist. Builders? What do you mean?Peipus
No sorry, builders where a wrong track, I am sure the annotation processor is on.Jokjakarta
@santirivera92 what is this "com.cidaut.blueparking.SplashScreen_"? I mean I think you have added library in your project.. am I right?Duralumin
@santirivera92 and also make sure you have check Android Private Libraries checked.. your all jar files should be in your Android Private Libs.Duralumin
Included all the Android libraries (4.2.2, Dependencies and Private libs). Now SplashScreen_ shows up but then I get a NoClassDefFoundError when I call MapScreen_.intent(this).start();Peipus
Added the Error Log which shows the class generation to the question.Peipus
have you checked true of Android Private Libs in the Java Build path? If yes then please update it in your question and please try to restarts once your eclipse.Duralumin
It is working now ^^ I edited the question with the complete solution. Thank you very much guys!Peipus
after 3 hours i found that with the default target/generated-sources/annotation Generadted source directory DONT WORKS! change name to other thing like target/generated-sources/aa and works trust meHusk
E
16

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

Epistemic answered 17/5, 2013 at 6:51 Comment(1)
Ok, you were partially right. The problem was not within the Order and Export tab of my project, but within the Order and Export tab of my libraries. Now I'm exporting everything in every project and it works again. Thank you very much!Peipus
C
10

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

Cherycherye answered 17/5, 2013 at 7:51 Comment(1)
This should be all that is needed.Askins
R
4

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.

Rodenticide answered 10/5, 2014 at 6:5 Comment(1)
Oh, wow, I spent ages on this. I'm using android-maven-plugin 3.9.0-rc.2 with ADT 22.6.3.v201404151837-1123206. I finally went to Properties|Java Build Path|Source and unchecked and rechecked "Allow output folders for source folders" (for both my application project and my library project) and did a clean build. This error went away! Strangely enough, I went back to the projects' properties, and this option is now unchecked! But at least my app is running now.Overblown
P
3

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.

Pyramidon answered 24/12, 2013 at 13:36 Comment(2)
You are right,, sometimes it happens because of JAR mismatchRespectively
Yup, for some reason when working on devices lower than API 21, having duplicate dependencies in a module and a project will cause this error. Too bad the stack trace doesn't provide a clue!Bunnybunow
S
1

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.

Shaveling answered 11/12, 2013 at 15:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.