Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bundletool version check when adding transparency file #367

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

littledog623
Copy link

@littledog623 littledog623 commented Jul 3, 2024

There is a bundletool compatibility issue when

  1. the bundle is built by a newer bundletool version through AGP.
  2. later is added the code transparency file with a older bundletool version.
  3. finally build apks with a newer bundletool version again. There will be error saying storearchive related dex is modified.

For example, I build an app bundle with AGP 8.5 (which uses bundletool 1.16.0 implicitly, which I was not aware of because the AGP release notes did not mention it 😢). Then I manually add the code transparency file using bundletool 1.15.0. Then, when I try to upload the bundle to play store, or use bundletool build-apks, there will be an error saying We have failed to run 'bundletool build-apks' on this Android App Bundle. Please ensure your bundle is valid by running 'bundletool build-apks' locally and try again. Error message output: Verification failed because code was modified after transparency metadata generation. Files deleted after transparency metadata generation: [/com/android/tools/build/bundletool/archive/dex/1_13_0/classes.dex] Files added after transparency metadata generation: [/com/android/tools/build/bundletool/archive/dex/1_16_0/classes.dex] Files modified after transparency metadata generation: []

The root cause

bundletool 1.15.0 and 1.16.0 provides different archive dex files. If the bundle is built by a newer bundletool but the code transparency is added by an older bundletool, there will be potential conflict in the transparency file if the final apks is generated by a new bundletool which provides a newer archive dex.

How to fix

Add a checker for bundle versions between the bundle and bundletool when generating the archive dex path to make sure archive dex version is correctly matched with the bundle version. Throw InvalidBundleException if code transparency is added by an older bundletool. We should make sure that the code transparency is always added by a newer bundletool because of the intrinsic version dependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant