use of com.android.bundle.Devices.DeviceSpec in project bundletool by google.
the class BuildApksDeviceSpecTest method deviceSpecMips_bundleTargetsX86_throws.
@Test
public void deviceSpecMips_bundleTargetsX86_throws() throws Exception {
DeviceSpec deviceSpec = mergeSpecs(sdkVersion(/* Lollipop */
21), abis("mips"), locales("en-US"), density(XHDPI));
bundleSerializer.writeToDisk(createX86AppBundle(), bundlePath);
BuildApksCommand command = BuildApksCommand.builder().setBundlePath(bundlePath).setOutputFile(outputFilePath).setDeviceSpec(deviceSpec).build();
Throwable exception = assertThrows(IncompatibleDeviceException.class, command::execute);
assertThat(exception).hasMessageThat().contains("The app doesn't support ABI architectures of the device. Device ABIs: [mips], " + "app ABIs: [x86]");
}
use of com.android.bundle.Devices.DeviceSpec in project bundletool by google.
the class BuildApksDeviceSpecTest method deviceSpec_correctStandaloneGenerated.
@Test
public void deviceSpec_correctStandaloneGenerated() throws Exception {
DeviceSpec deviceSpec = mergeSpecs(sdkVersion(19), abis("x86"), locales("en-US"), density(HDPI));
bundleSerializer.writeToDisk(createLdpiHdpiAppBundle(), bundlePath);
BuildApksCommand command = BuildApksCommand.builder().setBundlePath(bundlePath).setOutputFile(outputFilePath).setDeviceSpec(deviceSpec).build();
Path apksArchive = command.execute();
BuildApksResult result;
try (ZipFile apksZipFile = new ZipFile(apksArchive.toFile())) {
assertThat(apksZipFile).containsExactlyEntries("toc.pb", "standalones/standalone-hdpi.apk");
result = extractTocFromApkSetFile(apksZipFile, outputDir);
}
assertThat(result.getVariantList()).hasSize(1);
Variant variant = result.getVariant(0);
assertThat(variant.getApkSetList()).hasSize(1);
ApkSet apkSet = variant.getApkSet(0);
// One standalone APK.
assertThat(apkSet.getApkDescriptionList()).hasSize(1);
assertThat(apkNamesInSet(apkSet)).containsExactly("standalones/standalone-hdpi.apk");
}
use of com.android.bundle.Devices.DeviceSpec in project bundletool by google.
the class BuildApksDeviceSpecTest method deviceSpec_andConnectedDevice_throws.
@Test
public void deviceSpec_andConnectedDevice_throws() throws Exception {
DeviceSpec deviceSpec = deviceWithSdk(21);
AppBundle appBundle = new AppBundleBuilder().addModule("base", module -> module.setManifest(androidManifest("com.app"))).build();
bundleSerializer.writeToDisk(appBundle, bundlePath);
BuildApksCommand.Builder command = BuildApksCommand.builder().setBundlePath(bundlePath).setOutputFile(outputFilePath).setDeviceSpec(deviceSpec).setGenerateOnlyForConnectedDevice(true);
Throwable exception = assertThrows(InvalidCommandException.class, command::build);
assertThat(exception).hasMessageThat().contains("Cannot optimize for the device spec and connected device at the same time.");
}
use of com.android.bundle.Devices.DeviceSpec in project bundletool by google.
the class BuildApksDeviceSpecTest method deviceSpec_universalApk_throws.
@Test
public void deviceSpec_universalApk_throws() throws Exception {
DeviceSpec deviceSpec = deviceWithSdk(21);
AppBundle appBundle = new AppBundleBuilder().addModule("base", module -> module.setManifest(androidManifest("com.app"))).build();
bundleSerializer.writeToDisk(appBundle, bundlePath);
BuildApksCommand.Builder command = BuildApksCommand.builder().setBundlePath(bundlePath).setOutputFile(outputFilePath).setDeviceSpec(deviceSpec).setApkBuildMode(UNIVERSAL);
Throwable exception = assertThrows(InvalidCommandException.class, command::build);
assertThat(exception).hasMessageThat().contains("Optimizing for device spec is not possible when running with 'universal' mode flag.");
}
use of com.android.bundle.Devices.DeviceSpec in project bundletool by google.
the class BuildApksDeviceSpecTest method deviceSpec_systemApkMode_partialDeviceSpecMissingDensity_throws.
@Test
@Theory
public void deviceSpec_systemApkMode_partialDeviceSpecMissingDensity_throws() throws Exception {
DeviceSpec deviceSpec = mergeSpecs(abis("arm64-v8a"));
AppBundle appBundle = new AppBundleBuilder().addModule("base", module -> module.setManifest(androidManifest("com.app"))).build();
bundleSerializer.writeToDisk(appBundle, bundlePath);
BuildApksCommand.Builder command = BuildApksCommand.builder().setBundlePath(bundlePath).setOutputFile(outputFilePath).setDeviceSpec(deviceSpec).setApkBuildMode(SYSTEM);
Throwable exception = assertThrows(InvalidCommandException.class, command::build);
assertThat(exception).hasMessageThat().contains("Device spec must have screen density and ABIs set when running with 'system' mode" + " flag.");
}
Aggregations