Search in sources :

Example 1 with CommandExecutionException

use of com.android.tools.build.bundletool.model.exceptions.CommandExecutionException in project bundletool by google.

the class VariantGeneratorTest method targetsPreLOnlyInManifest_throws.

@Test
public void targetsPreLOnlyInManifest_throws() throws Exception {
    int preL = 20;
    BundleModule bundleModule = new BundleModuleBuilder("testModule").setManifest(androidManifest("com.test.app", withMaxSdkVersion(preL))).build();
    CommandExecutionException exception = assertThrows(CommandExecutionException.class, () -> new VariantGenerator().generateVariants(bundleModule));
    assertThat(exception).hasMessageThat().contains("does not target devices on Android L or above");
}
Also used : BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) CommandExecutionException(com.android.tools.build.bundletool.model.exceptions.CommandExecutionException) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 2 with CommandExecutionException

use of com.android.tools.build.bundletool.model.exceptions.CommandExecutionException in project bundletool by google.

the class BuildApksCommandTest method populateLineage_invalidFile.

@Test
public void populateLineage_invalidFile() {
    CommandExecutionException e = assertThrows(CommandExecutionException.class, () -> BuildApksCommand.fromFlags(new FlagParser().parse("--bundle=" + bundlePath, "--output=" + outputFilePath, "--aapt2=" + AAPT2_PATH, "--ks=" + keystorePath, "--ks-key-alias=" + KEY_ALIAS, "--ks-pass=pass:" + KEYSTORE_PASSWORD, "--key-pass=pass:" + KEY_PASSWORD, "--lineage=" + tmp.newFile(), "--oldest-signer=" + oldestSignerPropertiesPath), fakeAdbServer));
    assertThat(e).hasMessageThat().isEqualTo("The input file is not a valid lineage file.");
}
Also used : CommandExecutionException(com.android.tools.build.bundletool.model.exceptions.CommandExecutionException) FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Example 3 with CommandExecutionException

use of com.android.tools.build.bundletool.model.exceptions.CommandExecutionException in project bundletool by google.

the class ModuleSplitterTest method targetsPreLOnlyInManifest_throws.

@Test
public void targetsPreLOnlyInManifest_throws() throws Exception {
    int preL = 20;
    BundleModule bundleModule = new BundleModuleBuilder("testModule").setManifest(androidManifest("com.test.app", withMaxSdkVersion(preL))).build();
    CommandExecutionException exception = assertThrows(CommandExecutionException.class, () -> ModuleSplitter.createForTest(bundleModule, BUNDLETOOL_VERSION).splitModule());
    assertThat(exception).hasMessageThat().contains("does not target devices on Android L or above");
}
Also used : BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) CommandExecutionException(com.android.tools.build.bundletool.model.exceptions.CommandExecutionException) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 4 with CommandExecutionException

use of com.android.tools.build.bundletool.model.exceptions.CommandExecutionException in project bundletool by google.

the class D8DexMergerTest method mergeDoesNotFitIntoSingleDex_withoutMainDexList_preL_throws.

@Test
public void mergeDoesNotFitIntoSingleDex_withoutMainDexList_preL_throws() throws Exception {
    // The two input dex files cannot fit into a single dex file.
    Path dexFile1 = writeTestDataToFile("testdata/dex/classes-large.dex");
    Path dexFile2 = writeTestDataToFile("testdata/dex/classes-large2.dex");
    CommandExecutionException exception = assertThrows(CommandExecutionException.class, () -> new D8DexMerger().merge(ImmutableList.of(dexFile1, dexFile2), outputDir, /* mainDexListFile= */
    NO_FILE, /* proguardMap= */
    NO_FILE, /* isDebuggable= */
    false, /* minSdkVersion= */
    ANDROID_K_API_VERSION));
    assertThat(exception).hasMessageThat().contains("multidex is not supported by the input");
}
Also used : Path(java.nio.file.Path) CommandExecutionException(com.android.tools.build.bundletool.model.exceptions.CommandExecutionException) Test(org.junit.Test)

Example 5 with CommandExecutionException

use of com.android.tools.build.bundletool.model.exceptions.CommandExecutionException in project bundletool by google.

the class FusingAndroidManifestMergerTest method mergeChildrenMode_conflictMetadata_throws.

@Test
public void mergeChildrenMode_conflictMetadata_throws() {
    SetMultimap<BundleModuleName, AndroidManifest> manifests = createManifests(androidManifest("com.testapp", withActivity("myActivity", activity -> activity.addChildElement(XmlProtoElementBuilder.create("meta-data").addAttribute(XmlProtoAttributeBuilder.createAndroidAttribute(NAME_ATTRIBUTE_NAME, NAME_RESOURCE_ID).setValueAsString("meta")).addChildText("Base text")))), androidManifestForFeature("com.testapp.feature1", withActivity("myActivity", activity -> activity.addChildElement(XmlProtoElementBuilder.create("meta-data").addAttribute(XmlProtoAttributeBuilder.createAndroidAttribute(NAME_ATTRIBUTE_NAME, NAME_RESOURCE_ID).setValueAsString("meta")).addChildText("Feature text")))));
    CommandExecutionException exception = assertThrows(CommandExecutionException.class, () -> createMerger(Mode.MERGE_CHILDREN).merge(manifests));
    assertThat(exception).hasMessageThat().contains("Multiple meta-data entries with the same name are found inside activity:myActivity");
}
Also used : BundleModuleName(com.android.tools.build.bundletool.model.BundleModuleName) AndroidManifest(com.android.tools.build.bundletool.model.AndroidManifest) CommandExecutionException(com.android.tools.build.bundletool.model.exceptions.CommandExecutionException) Test(org.junit.Test)

Aggregations

CommandExecutionException (com.android.tools.build.bundletool.model.exceptions.CommandExecutionException)16 Test (org.junit.Test)16 Path (java.nio.file.Path)6 AndroidManifest (com.android.tools.build.bundletool.model.AndroidManifest)3 BundleModuleName (com.android.tools.build.bundletool.model.BundleModuleName)3 ApkTargeting (com.android.bundle.Targeting.ApkTargeting)2 BundleModule (com.android.tools.build.bundletool.model.BundleModule)2 BundleModuleBuilder (com.android.tools.build.bundletool.testing.BundleModuleBuilder)2 TargetingUtils.mergeApkTargeting (com.android.tools.build.bundletool.testing.TargetingUtils.mergeApkTargeting)2 FlagParser (com.android.tools.build.bundletool.flags.FlagParser)1