google/bundletool

"missing mandatory file 'manifest/AndroidManifest.xml'."

dean-ivre opened this issue · 6 comments

Describe the bug
"missing mandatory file 'manifest/AndroidManifest.xml'." getting this error when trying to use bundletool to zip up 2 apks to create a aab file.

Bundletool version(s) affected
bundletool-all-1.13.2

Stacktrace
Error: Module 'base' is missing mandatory file 'manifest/AndroidManifest.xml'.
com.android.tools.build.bundletool.model.exceptions.InvalidBundleException: Module 'test' is missing mandatory file 'manifest/AndroidManifest.xml'.
at com.android.tools.build.bundletool.model.exceptions.UserExceptionBuilder.build(UserExceptionBuilder.java:58)
at com.android.tools.build.bundletool.validation.MandatoryFilesPresenceValidator.checkModuleHasAndroidManifest(MandatoryFilesPresenceValidator.java:88)
at com.android.tools.build.bundletool.validation.MandatoryFilesPresenceValidator.validateModuleZipFile(MandatoryFilesPresenceValidator.java:43)
at com.android.tools.build.bundletool.validation.ValidatorRunner.lambda$validateModuleZipFile$2(ValidatorRunner.java:54)
at com.google.common.collect.ImmutableList.forEach(ImmutableList.java:422)
at com.android.tools.build.bundletool.validation.ValidatorRunner.validateModuleZipFile(ValidatorRunner.java:54)
at com.android.tools.build.bundletool.validation.BundleModulesValidator.validate(BundleModulesValidator.java:71)
at com.android.tools.build.bundletool.commands.BuildBundleCommand.execute(BuildBundleCommand.java:231)
at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:78)
at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:54)

To Reproduce
Steps to reproduce the behavior.
copy 2 apks into base directory
compress base folder
run this command in terminal - java -jar /Users/XXXX/Downloads/bundletool-all-1.13.2.jar build-bundle --modules base.zip --output bundle.aab

Expected behavior
output file should show with contained apks.

Known workaround
could not find one

Environment:
OS: macOS Monterey - 12.6

Additional context

The problem may stem from the fact that the manifest file is stored in the root folder in the APK archive. In this case you need to create a manifest folder in the APK and then move the manifest file in this folder. For instance let us say you have the following APK archive:

res (directory)
lib (directory)
AndroidManifest.xml
resources.pb

You need to modify it to have the following layout:

res (directory)
lib (directory)
manifest (directory)
    AndroidManifest.xml
resources.pb

From the documentation: https://developer.android.com/studio/build/building-cmdline#package_pre-compiled_code_and_resources

Hope this helps.

AAB file can not be created from APKs. Module file format is different from APK, check out here:
https://developer.android.com/studio/build/building-cmdline#package_pre-compiled_code_and_resources.

so what I am trying to achieve is I have 2 apks in a zip and I want to bundle these to create a aab file to upload to play store
Can this not be done?

I dont build the apks from android studio

There is no command in bundletool which supports this and there are no plans to support such flow out of the box.

You might be able to do this, but this is an bundletool issue tracker and your question is outside of the scope of bunldetool. Try stackoverflow.

no problem thank you very much