1

The scene: I have a directory structure like the following:

mkdir -p foo/bar  
touch foo/bar/test.txt

What I want to do is to add test.txt to a .apk under the directory foo/bar, so that uncompressing or listing the apk returns the same directory structure.

This worked fine under the 1.6 SDK:

aapt add test.apk foo/bar/test.txt

I could list and uncompress test.apk and all was well. Under 2.1, however, test.txt is added to the root of test.apk, which isn't what I want.

I just tested this under the 2.1 SDK on my desktop and the older 1.6 version on my laptop, and I've confirmed that it used to work and now doesn't.

I've looked at the aapt command line options, and if there's a --keep-the-files-i-add-in-their-subdirectories option then I'm just not seeing it. :/ Googling is also not returning anything useful.

Would really appreciate help with this. I need to store third-party .properties files in my Android application so they're on the classpath, and my inability to find the right command line incantations is the only blocker keeping this app off of 2.1. :)

Thanks a bunch.

Nolan
  • 2,209
  • 3
  • 18
  • 20

1 Answers1

0

The behaviour you see is a bug in AAPT. You may find more info on this at Repackage APK file to contain custom assets - what build tool to use?.

There are broken versions of AAPT in some of the SDKs. The correct behaviour is that it should work as you describe, but I also struggled to get it working.

Unfortunately I cannot tell you which SDK has a working AAPT version - it was through trial and error that someone in our office found it, and so we have archived it for our dev purposes and now we only use that copy.

So the solution is to download many of the SDKs, and try each AAPT (suck, laborious, and not really a good solution, but it works). AAPT is great when you can get it right.

We have used it to target 2.1 but I'm not sure it was the 2.1 SDK version that we used.

(and no, googling this didn't help me either - too much noise about the issue sadly).

Community
  • 1
  • 1
Richard Le Mesurier
  • 29,432
  • 22
  • 140
  • 255