Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is actually a bug in <code>aapt</code> that will make this randomly impossible. The way it is supposed to work is as the other answer claims: paths are kept, unless you pass <code>-k</code>. Let's see how this is implemented:</p> <p>The flag that controls whether the path is ignored is <code>mJunkPath</code>:</p> <pre><code>bool mJunkPath; </code></pre> <p>This variable is in a class called <code>Bundle</code>, and is controlled by two accessors:</p> <pre><code>bool getJunkPath(void) const { return mJunkPath; } void setJunkPath(bool val) { mJunkPath = val; } </code></pre> <p>If the user specified <code>-k</code> at the command line, it is set to <code>true</code>:</p> <pre><code>case 'k': bundle.setJunkPath(true); break; </code></pre> <p>And, when the data is being added to the file, it is checked:</p> <pre><code>if (bundle-&gt;getJunkPath()) { String8 storageName = String8(fileName).getPathLeaf(); printf(" '%s' as '%s'...\n", fileName, storageName.string()); result = zip-&gt;add(fileName, storageName.string(), bundle-&gt;getCompressionMethod(), NULL); } else { printf(" '%s'...\n", fileName); result = zip-&gt;add(fileName, bundle-&gt;getCompressionMethod(), NULL); } </code></pre> <p>Unfortunately, the one instance of <code>Bundle</code> used by the application is allocated in <code>main</code> on the stack, and there is no initialization of <code>mJunkPath</code> in the constructor, so the value of the variable is random; without a way to explicitly set it to <code>false</code>, on my system I (seemingly deterministically) am unable to add files at specified paths.</p> <p>However, you can also just use <code>zip</code>, as an APK is simply a Zip file, and the <code>zip</code> tool works fine.</p> <p>(For the record, I have not submitted the trivial fix for this as a patch to Android yet, if someone else wants to the world would likely be a better place. My experience with the Android code submission process was having to put up with an incredibly complex submission mechanism that in the end took six months for someone to get back to me, in some cases with minor modifications that could have just been made on their end were their submission process not so horribly complex. Given that there is a really easy workaround to this problem, I do not consider it important enough to bother with all of that again.)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload