0

I have a Android project with some classes that I would like to compress to a JAR.

I create the JAR by right clicking my project - export - JAR - and the JAR gets created without any warnings.

I can access all classes from the JAR in my code but when I try to build the project get this exception :

java.lang.NoClassDefFoundError: name.of.class.in.package

Does anyone know what resources should be exported with the JAR? The options you get is

.class path
.prject
AndroidManifest.xml
proguard.cfg
project.properties 

Right now I have included all of the above.

Making the JAR into a library project is not an option. And just to make it clear I don't have anything in the RES folder of my JAR project.

Community
  • 1
  • 1
Slickelito
  • 1,786
  • 20
  • 28

4 Answers4

0

Just add your JAR to classpath or build your project with Maven and include dependencies

skayred
  • 10,603
  • 10
  • 52
  • 94
0

Open the project properties -> Java Build Path -> Order and Export and check item Android Dependencies are checked to be exported to the result APK.

And if .jar exist in Library tab under Android Dependencies item.

If you have .jar in the "libs" folder it should be included by default.

ATom
  • 15,960
  • 6
  • 46
  • 50
0

Try generating the jar in a different way. Basically jar is a zipped file of all class files with an extension of .jar.

  1. Select all your class files that needs to be included in a jar file.
  2. Right click and send to compressed (Zip File).
  3. you will have a zipped file which will contain all the class files.
  4. Rename this zipped file with having an extension .jar

Now include this jar file into your project whichever you want to use.

Or if you want to zip all the files by a different method then make sure all the files are zipped together without a folder. So when you unzip the files you should get all the files without contained in a folder.

user_CC
  • 4,686
  • 3
  • 20
  • 15
0

It looks similar with this topic. Follow the very clear instructions written by Russ Bateman.

Community
  • 1
  • 1
Jan
  • 400
  • 5
  • 14
  • Turns out you could do it that way or just make sure the Android Dependencies are checked for export under the Order and Export. – Slickelito May 24 '12 at 05:35