Search in sources :

Example 6 with IncompatibleDeviceException

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

the class BundleToolErrorTest method testIncompatibleDevice.

@Test
public void testIncompatibleDevice() {
    IncompatibleDeviceException exception = IncompatibleDeviceException.builder().withUserMessage("user msg").build();
    assertError(exception.toProto(), ErrorType.INCOMPATIBLE_DEVICE_ERROR, "user msg", "user msg");
}
Also used : IncompatibleDeviceException(com.android.tools.build.bundletool.model.exceptions.IncompatibleDeviceException) Test(org.junit.Test)

Example 7 with IncompatibleDeviceException

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

the class ExtractApksCommandTest method extractInstant_withNoInstantModules.

@Test
public void extractInstant_withNoInstantModules() throws Exception {
    ZipPath apkPreL = ZipPath.create("apkPreL.apk");
    ZipPath apkLBase = ZipPath.create("apkL-base.apk");
    ZipPath apkLFeature = ZipPath.create("apkL-feature.apk");
    ZipPath apkLOther = ZipPath.create("apkL-other.apk");
    BuildApksResult tableOfContentsProto = BuildApksResult.newBuilder().setBundletool(Bundletool.newBuilder().setVersion(BundleToolVersion.getCurrentVersion().toString())).addVariant(createVariant(variantSdkTargeting(sdkVersionFrom(21), ImmutableSet.of(SdkVersion.getDefaultInstance())), createStandaloneApkSet(ApkTargeting.getDefaultInstance(), apkPreL))).addVariant(createVariant(variantSdkTargeting(sdkVersionFrom(21), ImmutableSet.of(SdkVersion.getDefaultInstance())), createSplitApkSet("base", createMasterApkDescription(ApkTargeting.getDefaultInstance(), apkLBase)), createSplitApkSet("feature", createMasterApkDescription(ApkTargeting.getDefaultInstance(), apkLFeature)), createSplitApkSet("other", createMasterApkDescription(ApkTargeting.getDefaultInstance(), apkLOther)))).build();
    Path apksArchiveFile = createApksArchiveFile(tableOfContentsProto, tmpDir.resolve("bundle.apks"));
    DeviceSpec deviceSpec = deviceWithSdk(21);
    IncompatibleDeviceException exception = assertThrows(IncompatibleDeviceException.class, () -> ExtractApksCommand.builder().setApksArchivePath(apksArchiveFile).setDeviceSpec(deviceSpec).setInstant(true).build().execute());
    assertThat(exception).hasMessageThat().contains("No compatible APKs found for the device");
}
Also used : Path(java.nio.file.Path) ZipPath(com.android.tools.build.bundletool.model.ZipPath) DeviceSpec(com.android.bundle.Devices.DeviceSpec) BuildApksResult(com.android.bundle.Commands.BuildApksResult) ZipPath(com.android.tools.build.bundletool.model.ZipPath) IncompatibleDeviceException(com.android.tools.build.bundletool.model.exceptions.IncompatibleDeviceException) Test(org.junit.Test)

Example 8 with IncompatibleDeviceException

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

the class ExtractApksCommandTest method extractApks_aboveMaxSdk_throws.

@Test
public void extractApks_aboveMaxSdk_throws() throws Exception {
    BuildApksResult tableOfContentsProto = BuildApksResult.newBuilder().setBundletool(Bundletool.newBuilder().setVersion(BundleToolVersion.getCurrentVersion().toString())).addVariant(createVariant(variantSdkTargeting(// The variant contains a fake alternative to limit the matching up to 23.
    sdkVersionFrom(21), ImmutableSet.of(sdkVersionFrom(24))), createSplitApkSet("base", createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("base-master.apk"))))).build();
    Path apksArchiveFile = createApksArchiveFile(tableOfContentsProto, tmpDir.resolve("bundle.apks"));
    DeviceSpec deviceSpec = deviceWithSdk(26);
    IncompatibleDeviceException exception = assertThrows(IncompatibleDeviceException.class, () -> ExtractApksCommand.builder().setApksArchivePath(apksArchiveFile).setDeviceSpec(deviceSpec).setInstant(true).build().execute());
    assertThat(exception).hasMessageThat().contains("No compatible APKs found for the device");
}
Also used : Path(java.nio.file.Path) ZipPath(com.android.tools.build.bundletool.model.ZipPath) DeviceSpec(com.android.bundle.Devices.DeviceSpec) BuildApksResult(com.android.bundle.Commands.BuildApksResult) IncompatibleDeviceException(com.android.tools.build.bundletool.model.exceptions.IncompatibleDeviceException) Test(org.junit.Test)

Example 9 with IncompatibleDeviceException

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

the class ExtractApksCommandTest method incompleteApksFile_missingMatchedAbiSplit_throws.

@Test
public void incompleteApksFile_missingMatchedAbiSplit_throws() throws Exception {
    // Partial APK Set file where 'x86' split is included and 'x86_64' split is not included because
    // device spec sent to 'build-apks' command doesn't support it.
    // Next, device spec that should be matched to 'x86_64' split is provided to 'extract-apks'
    // command and command throws IncompatibleDeviceException.
    BuildApksResult tableOfContent = BuildApksResult.newBuilder().setBundletool(Bundletool.newBuilder().setVersion(BundleToolVersion.getCurrentVersion().toString())).addVariant(createVariant(VariantTargeting.getDefaultInstance(), createSplitApkSet(/* moduleName= */
    "base", createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("base-master.apk")), splitApkDescription(apkAbiTargeting(X86, ImmutableSet.of(X86_64)), ZipPath.create("base-x86.apk"))))).build();
    Path apksArchiveFile = createApksArchiveFile(tableOfContent, tmpDir.resolve("bundle.apks"));
    DeviceSpec deviceSpec = mergeSpecs(deviceWithSdk(21), abis("x86_64", "x86"));
    ExtractApksCommand command = ExtractApksCommand.builder().setDeviceSpec(deviceSpec).setApksArchivePath(apksArchiveFile).setOutputDirectory(tmpDir).build();
    IncompatibleDeviceException exception = assertThrows(IncompatibleDeviceException.class, command::execute);
    assertThat(exception).hasMessageThat().isEqualTo("Missing APKs for [ABI] dimensions in the module 'base' for the provided device.");
}
Also used : Path(java.nio.file.Path) ZipPath(com.android.tools.build.bundletool.model.ZipPath) DeviceSpec(com.android.bundle.Devices.DeviceSpec) BuildApksResult(com.android.bundle.Commands.BuildApksResult) IncompatibleDeviceException(com.android.tools.build.bundletool.model.exceptions.IncompatibleDeviceException) Test(org.junit.Test)

Example 10 with IncompatibleDeviceException

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

the class ApkMatcherTest method apexVariantMatch_noMatch_throws.

// APEX variants tests.
@Test
public void apexVariantMatch_noMatch_throws() {
    ZipPath x86Apk = ZipPath.create("standalone-x86.apk");
    ZipPath x64X86Apk = ZipPath.create("standalone-x86_64.x86.apk");
    ImmutableSet<ImmutableSet<AbiAlias>> x86Set = ImmutableSet.of(ImmutableSet.of(X86));
    ImmutableSet<ImmutableSet<AbiAlias>> x64X86Set = ImmutableSet.of(ImmutableSet.of(X86_64, X86));
    MultiAbiTargeting x86Targeting = multiAbiTargeting(x86Set, x64X86Set);
    MultiAbiTargeting x64X86Targeting = multiAbiTargeting(x64X86Set, x86Set);
    BuildApksResult buildApksResult = BuildApksResult.newBuilder().addVariant(multiAbiTargetingApexVariant(x86Targeting, x86Apk)).addVariant(multiAbiTargetingApexVariant(x64X86Targeting, x64X86Apk)).build();
    IncompatibleDeviceException e = assertThrows(IncompatibleDeviceException.class, () -> new ApkMatcher(abis("x86_64", "armeabi-v7a")).getMatchingApks(buildApksResult));
    assertThat(e).hasMessageThat().contains("No set of ABI architectures that the app supports is contained in the ABI " + "architecture set of the device");
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) BuildApksResult(com.android.bundle.Commands.BuildApksResult) ZipPath(com.android.tools.build.bundletool.model.ZipPath) IncompatibleDeviceException(com.android.tools.build.bundletool.model.exceptions.IncompatibleDeviceException) MultiAbiTargeting(com.android.bundle.Targeting.MultiAbiTargeting) Test(org.junit.Test)

Aggregations

IncompatibleDeviceException (com.android.tools.build.bundletool.model.exceptions.IncompatibleDeviceException)12 ZipPath (com.android.tools.build.bundletool.model.ZipPath)10 Test (org.junit.Test)10 BuildApksResult (com.android.bundle.Commands.BuildApksResult)8 DeviceSpec (com.android.bundle.Devices.DeviceSpec)5 Path (java.nio.file.Path)5 ImmutableSet (com.google.common.collect.ImmutableSet)4 MultiAbiTargeting (com.android.bundle.Targeting.MultiAbiTargeting)2 BadgingInfo (com.android.tools.build.bundletool.device.BadgingInfoParser.BadgingInfo)2 TempDirectory (com.android.tools.build.bundletool.io.TempDirectory)2 Variant (com.android.bundle.Commands.Variant)1 Aapt2Command (com.android.tools.build.bundletool.androidtools.Aapt2Command)1 AdbCommand (com.android.tools.build.bundletool.androidtools.AdbCommand)1 CommandDescription (com.android.tools.build.bundletool.commands.CommandHelp.CommandDescription)1 FlagDescription (com.android.tools.build.bundletool.commands.CommandHelp.FlagDescription)1 ANDROID_SERIAL_VARIABLE (com.android.tools.build.bundletool.commands.CommandUtils.ANDROID_SERIAL_VARIABLE)1 AdbServer (com.android.tools.build.bundletool.device.AdbServer)1 AdbShellCommandTask (com.android.tools.build.bundletool.device.AdbShellCommandTask)1 BadgingInfoParser (com.android.tools.build.bundletool.device.BadgingInfoParser)1 Device (com.android.tools.build.bundletool.device.Device)1