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");
}
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");
}
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");
}
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.");
}
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");
}
Aggregations