use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.
the class AndroidManifestValidatorTest method instantAssetModuleWithInstallTimeDelivery_throws.
@Test
public void instantAssetModuleWithInstallTimeDelivery_throws() throws Exception {
BundleModule module = new BundleModuleBuilder("assetmodule").setManifest(androidManifestForAssetModule(PKG_NAME, withInstallTimeDelivery(), withInstantOnDemandDelivery())).build();
InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new AndroidManifestValidator().validateModule(module));
assertThat(exception).hasMessageThat().startsWith("Instant asset packs cannot have install-time delivery (module 'assetmodule').");
}
use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.
the class BuildApksManagerTest method buildApksCommand_standalone_mixedTextureTargetingInDifferentPacksWithSameFolderName.
@Test
public void buildApksCommand_standalone_mixedTextureTargetingInDifferentPacksWithSameFolderName() throws Exception {
AppBundle appBundle = new AppBundleBuilder().addModule("base", builder -> builder.setManifest(androidManifest("com.test.app"))).addModule("feature_tcf_assets", builder -> builder.addFile("assets/textures/untargeted_texture.dat").addFile("assets/textures#tcf_etc1/etc1_texture.dat").setAssetsConfig(assets(targetedAssetsDirectory("assets/textures", assetsDirectoryTargeting(alternativeTextureCompressionTargeting(ETC1_RGB8))), targetedAssetsDirectory("assets/textures#tcf_etc1", assetsDirectoryTargeting(textureCompressionTargeting(ETC1_RGB8))))).setManifest(androidManifest("com.test.app", withDelivery(DeliveryType.INSTALL_TIME), withFusingAttribute(true)))).addModule("feature_assets_without_tcf", builder -> builder.addFile("assets/textures/another_untargeted_texture.dat").setAssetsConfig(assets(targetedAssetsDirectory("assets/textures", AssetsDirectoryTargeting.getDefaultInstance()))).setManifest(androidManifest("com.test.app", withDelivery(DeliveryType.INSTALL_TIME), withFusingAttribute(true)))).setBundleConfig(BundleConfigBuilder.create().addSplitDimension(Value.TEXTURE_COMPRESSION_FORMAT, /* negate= */
false, /* stripSuffix= */
true, /* defaultSuffix= */
"").build()).build();
TestComponent.useTestModule(this, createTestModuleBuilder().withAppBundle(appBundle).withOutputPath(outputFilePath).withOptimizationDimensions(TEXTURE_COMPRESSION_FORMAT).build());
InvalidBundleException e = assertThrows(InvalidBundleException.class, () -> buildApksManager.execute());
assertThat(e).hasMessageThat().contains("Encountered conflicting targeting values while merging assets config.");
}
use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.
the class BundleModuleMergerTest method testMultipleModulesWithInstallTime_throws_duplicateModuleEntriesWithDifferentContent.
@Test
public void testMultipleModulesWithInstallTime_throws_duplicateModuleEntriesWithDifferentContent() throws Exception {
XmlNode installTimeModuleManifest = androidManifestForFeature("com.test.app.detail", withInstallTimeDelivery());
createBasicZipBuilder(BUNDLE_CONFIG_1_0_0).addFileWithProtoContent(ZipPath.create("base/manifest/AndroidManifest.xml"), MANIFEST).addFileWithContent(ZipPath.create("base/dex/classes.dex"), DUMMY_CONTENT).addFileWithContent(ZipPath.create("base/assets/baseAssetfile.txt"), DUMMY_CONTENT).addFileWithProtoContent(ZipPath.create("detail1/manifest/AndroidManifest.xml"), installTimeModuleManifest).addFileWithContent(ZipPath.create("detail1/assets/detailsAssetfile.txt"), DUMMY_CONTENT).addFileWithProtoContent(ZipPath.create("detail2/manifest/AndroidManifest.xml"), installTimeModuleManifest).addFileWithContent(ZipPath.create("detail2/assets/baseAssetfile.txt"), DUMMY_CONTENT_2).writeTo(bundleFile);
try (ZipFile appBundleZip = new ZipFile(bundleFile.toFile())) {
InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> BundleModuleMerger.mergeNonRemovableInstallTimeModules(AppBundle.buildFromZip(appBundleZip), /* overrideBundleToolVersion = */
false));
assertThat(exception).hasMessageThat().contains("Existing module entry 'assets/baseAssetfile.txt' with different contents.");
}
}
use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.
the class AndroidManifestTest method getUsesSplits_missingNameAttribute_throws.
@Test
public void getUsesSplits_missingNameAttribute_throws() {
AndroidManifest androidManifest = AndroidManifest.create(xmlNode(xmlElement("manifest", xmlNode(xmlElement("uses-split")))));
InvalidBundleException exception = assertThrows(InvalidBundleException.class, androidManifest::getUsesSplits);
assertThat(exception).hasMessageThat().contains("<uses-split> element is missing the 'android:name' attribute");
}
use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.
the class AndroidManifestTest method getIsIncludedInFusing_missingIncludeAttribute_forSplit_legacy_throws.
@Test
public void getIsIncludedInFusing_missingIncludeAttribute_forSplit_legacy_throws() {
AndroidManifest androidManifest = AndroidManifest.create(xmlNode(xmlElement("manifest", xmlAttribute("split", "feature1"), xmlNode(xmlElement(DISTRIBUTION_NAMESPACE_URI, "module", xmlNode(xmlElement(DISTRIBUTION_NAMESPACE_URI, "fusing")))))), BUNDLE_TOOL_0_3_3);
InvalidBundleException exception = assertThrows(InvalidBundleException.class, androidManifest::getIsModuleIncludedInFusing);
assertThat(exception).hasMessageThat().isEqualTo("<fusing> element is missing the 'include' attribute (split: 'feature1').");
}
Aggregations