2

I'm using SpartacusRex's Terminal IDE and another app, DroidEdit, to build and run java applications on Android. A simle one-file Hello World builds and runs flawlessly, however when i introduce packages i cannot properly dex the class files into a jar file:

From my project directory:
javac src/mypack/*.java
This Compiles Successully
dx --dex --output=Test.jar src
This gives my the following warning

trouble processing:
class name (mypack/Main) does not match path (Main.class)
... while parsing Main.class
... while processing Main.class

All paths and package names are correct. Main.java is in a folder called "mypack" and has a packgage statement "package mypack;".
What am I doing wrong ? Also, using --no-strict removes the warning but the outputted jar file is not built correctly and cannot be run.

Any help is appreciated. Thanks :)

Zyyk Savvins
  • 483
  • 4
  • 8
  • 14

3 Answers3

6

You must put the class files inside a directory named exactly like it's package name and then create the jar file from it.

for example com.test.me.MyActivity must be at com/test/me/MyActivity.class

Hossein Shahdoost
  • 1,692
  • 18
  • 32
0

According to your question all *.class files are in mypack/ directory so issue following command it might help you.

dx --dex --output=classes.dex src/mypack/

dx will pick all the files from mypack directly. Consider reading this SO question.

Community
  • 1
  • 1
Imposter
  • 2,666
  • 1
  • 21
  • 31
0

I have the same development environment and the same problem. the sollution is to use intermediate jars.

  1. first compile the classes with packages. javac -d classes $srclist
  2. create intermediate jars (only 1 arg allowed) jar cf $idedir/a.jar a jar cf $idedir/b.jar b
  3. create executable dx jar dx --dex --verbose --output=$jarfile $idedir/a.jar $idedir/b.jar

then the dx jar has the correct package for each class

Daniel Langdon
  • 5,899
  • 4
  • 28
  • 48