title: Rename package name using aapt
body: <p>For debugging reasons, I need to install more instances of my app. I found that the app identifier is located in binary AndroidManifest.xml in APK file so I don't have to mess with the app identifier at the project level that has unwanted consequences.</p>
  
  <p>Note that there are similar questions on stackoverflow but none of them can answer this, as far as I know.</p>
  
  <p>The rename should be as easy as running the following command: (where <code>apk_dir</code> is the directory where the original APK was extracted to)</p>
  
  <pre><code>aapt package -v --rename-manifest-package com.xyz.abc apk_dir
  </code></pre>
  
  <p>However, it merely enumerates all the resources in the <code>apk</code> directory. Nothing changes, no error message is printed. This is quite confusing - when I instruct a tool to make changes that it can't make, it should let me know clearly it was not done.</p>
  
  <p>There are few 3rd party tools that I don't want to use because the official <code>appt</code> tool should be able to change the package name (and because the other tools have issues). It seems to be a powerfull tool but it is underdocumented. However, the help it prints seems promising:</p>
  
  <pre><code>--rename-manifest-package
     Rewrite the manifest so that its package name is the package name
     given here.  Relative class names (for example .Foo) will be
     changed to absolute names with the old package so that the code
     does not need to change.
  </code></pre>
  
  <p>It is also very unfortunate that there are two formats of AndroidManifest.xml. Besides the expected one there is the binary (compiled) manifest XML file that is packed into the APK file. This doesn't make reading documentation easier.</p>