diff --git a/src/main/java/com/android/tools/build/bundletool/transparency/CodeTransparencyFactory.java b/src/main/java/com/android/tools/build/bundletool/transparency/CodeTransparencyFactory.java index bbedbc55..d84b32d5 100644 --- a/src/main/java/com/android/tools/build/bundletool/transparency/CodeTransparencyFactory.java +++ b/src/main/java/com/android/tools/build/bundletool/transparency/CodeTransparencyFactory.java @@ -26,6 +26,7 @@ import com.android.tools.build.bundletool.model.BundleModule; import com.android.tools.build.bundletool.model.ModuleEntry; import com.android.tools.build.bundletool.model.exceptions.InvalidBundleException; +import com.android.tools.build.bundletool.model.version.BundleToolVersion; import com.google.common.collect.ImmutableList; import com.google.common.hash.Hashing; import com.google.common.io.ByteSource; @@ -51,8 +52,13 @@ public static CodeTransparency createCodeTransparencyMetadata(AppBundle bundle) CodeTransparency.newBuilder() .setVersion(CodeTransparencyVersion.getCurrentVersion()) .addAllCodeRelatedFile(codeRelatedFiles); - if (bundle.getStoreArchive().orElse(true)) { + if (BundleToolVersion.getCurrentVersion().compareTo(bundle.getVersion()) <= 0) { + throw InvalidBundleException.builder() + .withUserMessage("This bundletool version is lower than the one that is used to build the app bundle. " + + "Please use a bundletool with version >= " + bundle.getVersion()) + .build(); + } codeTransparencyBuilder.addCodeRelatedFile(createArchivedCodeRelatedFile(bundle)); }