Search code examples
javaandroideclipsenoclassdeffounderrorbuildpath

referencing (pure java) project in Android project (Could not find class)


I am trying to reference a pure java-Project in my Android-Project -> The Java-Project has a whole bunch of classes I need to use. Oh, and as the first response pointed out: I am using eclipse, yes :)
Only Problem is: I Always get Could not find class 'XXX', referenced from method com.example.helloworld.MainActivity.onCreate. I seem to have missed SOME step or error...?
What I already did:

  • The Project is added as Project into the Java Build Path (logically nessecary)
  • It is marked in "Order and Export" in the Java Build Path and pushed to the top (this solved the problem for someone else here when dealing with Jar-files)
  • Ir is marked in "Project References" on Project settings.
  • I added the folder where the relevant class is under "Libraries" in build Path... I am not sure if that should be nessecary.

The Java-Project I reference has a whole load of Jars, but if that is the reason, should I not get a different errormessage?


Solution

  • I had the same issue and after some hours of frustration and search I have finally found the answer here: Android, class not found from imported jar file

    Basically, the issue was that the referenced pure-java project or the generated jar was built with Java 1.7, and Android projects are set to use 1.6.