4

I've generated the .aab file using the ./gradlew bundle command. Latter unzipped the .aab got resources and dex files. Now I want to change some version code in AndroidManifest.xml, some resource files, and again need to recompile the same .aab file.

In the case of .apk, we can achieve using APKTool(reverse engineering) this working perfectly.

Since we have to move from APK to AAB, I'm unable to rebuild after modification .aab file. Please give your pointers on how to do this using the commands?.

Thanks in advance!!

2 Answers2

3

You can use bundletool to do so if you only need to change assets, I have not yet tested if you can alter sources as with APK+apktool.

BundleTool:

Alter AAB files:

  1. Extract the BUILD.aab to the same directory where bundletool.jar is.

  2. Open terminal and execute the following command to extract the aab zip.

    unzip BUILD.aab -d ./aab_unpack

  3. Once finished, search directory for the files you want to edit. As a recommendation use terminal or an script editor to avoid creating .DS_STORE files.

  4. In case you need it, move to root of aab_unpack and delete the .DS_STORE files with the next command: find . -name ".DS_Store" -delete

  5. Move to aab_unpack/base folder and create a base.zip under the same directory where bundletool.jar is. Use the next command:

    zip -r --no-dir-entries ../../base.zip *

  6. Repack using bundletool.jar

    java -jar bundletool.jar build-bundle --modules base.zip --output BUILD_REPACK.aab

  7. Verify the aab file generated with the next command

    java -jar bundletool.jar validate --bundle BUILD_REPACK.aab

You should get a message like this:

enter image description here

  1. Sign the abb file with jarsigner

    /Library/Java/JavaVirtualMachines/jdk-11.0.4.jdk/Contents/Home/bin/jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore YOUR_KEY.jks -signedjar BUILD_OUTPUT_SIGNED.aab BUILD_REPACK.aab ALIAS_NAME

htafoya
  • 18,261
  • 11
  • 80
  • 104
  • I want to make change my app name for that I need to modify my resources.pb file which is compiled and can be edited without doing Serialization do you have any way to edit it? – Maveňツ May 28 '22 at 19:59
-2

Generally we recommend not to manipulate the .aab file manually but let bundletool do the task.

The recommendation is to use ./gradlew bundle as you have done in the first instance, after applying changes to the project that is being built. The resulting .aab file will contain these changes.
This means you won't have to manipulate the contents by hand.

Ben Weiss
  • 17,182
  • 6
  • 67
  • 87
  • 1
    After the first instance, assume that I don't have the source code and android studio. I just want to change the app name in resources at runtime using the first instance .aab file. And making these changes I want to rebuild the .aab file. In the case of APK, we could able to do this using the APKTool without source code. – Prasanna Kumar Peddinti Nov 08 '20 at 02:29
  • The existing and official tooling does not support that use case at this time. We recommend you use the path outline in above answer. – Ben Weiss Nov 09 '20 at 12:20
  • 1
    Thanks, @keyboardsurfer. I got it. is there any way to edit the resources.pb file at runtime and recompile back to .pb file. – Prasanna Kumar Peddinti Nov 10 '20 at 06:32
  • @PrasannaKumarPeddinti hey bro did you got any solution to this? – Maveňツ May 28 '22 at 19:54