Search code examples
androidbashscriptingaapt

aapt not working with absolute path


I have a kind of strange issue. In my bash script or Makefile, using aapt with absolute path does not work but if I am in the local directory it does.

If I do the following, it does not work:

aapt add $OUT/device.jar $OUT/classes.dex

The command does run and print this output:

 '/homes/rsevile/CS307/bin/Device/classes.dex'...

But when trying to load the jar, the class that I am trying to load end up being not found.

The following does work though:

cd $OUT
aapt add device.jar classes.dex

Printing:

 'classes.dex'...

This is the whole code being executed in the script (which works):

javac -d $(OUT)/classes -classpath ./layoutlib.jar src/com/device/client/*.java
jar cf $(OUT)/device.jar $(OUT)/classes $(OUT)/layoutlib
dx --dex --no-strict --output=$OUT/classes.dex $OUT/device.jar 
cd $OUT
aapt add device.jar classes.dex
cd $ROOT
adb push $OUT/device.jar $ANDROID_OUT_DIR

I am confused why my class ends up being not found when using an absolute path with aapt.

Could anyone please explain to me why it is not working and how I could fix it to use a proper absolute path please?

Thank you.


Solution

  • I realized that aapt actually keeps the absolute path, there is no way around it.

    I fixed the problem by reusing jar and using the -C option that lets me specify a directory.