use of com.android.tools.build.bundletool.io.AppBundleSerializer in project bundletool by google.
the class BuildApksPreprocessingTest method renderscript32Bit_64BitStandaloneAndSplitApksFilteredOut.
@Test
public void renderscript32Bit_64BitStandaloneAndSplitApksFilteredOut() throws Exception {
AppBundle appBundle = new AppBundleBuilder().addModule("base", module -> module.addFile("dex/classes.dex").addFile("assets/script.bc").addFile("lib/armeabi-v7a/libfoo.so").addFile("lib/arm64-v8a/libfoo.so").setManifest(androidManifest("com.test.app", withMinSdkVersion(14))).setNativeConfig(nativeLibraries(targetedNativeDirectory("lib/armeabi-v7a", nativeDirectoryTargeting(ARMEABI_V7A)), targetedNativeDirectory("lib/arm64-v8a", nativeDirectoryTargeting(ARM64_V8A))))).setBundleConfig(BundleConfigBuilder.create().setUncompressNativeLibraries(false).build()).build();
new AppBundleSerializer().writeToDisk(appBundle, bundlePath);
BuildApksCommand command = BuildApksCommand.builder().setBundlePath(bundlePath).setOutputFile(outputFilePath).build();
command.execute();
BuildApksResult result;
try (ZipFile apkSetFile = new ZipFile(outputFilePath.toFile())) {
result = extractTocFromApkSetFile(apkSetFile, outputDir);
}
assertThat(standaloneApkVariants(result)).hasSize(1);
assertThat(standaloneApkVariants(result).get(0).getTargeting().getAbiTargeting()).isEqualTo(abiTargeting(ARMEABI_V7A));
assertThat(splitApkVariants(result)).hasSize(1);
ImmutableSet<AbiTargeting> abiTargetings = splitApkVariants(result).get(0).getApkSetList().stream().map(ApkSet::getApkDescriptionList).flatMap(list -> list.stream().map(ApkDescription::getTargeting)).map(ApkTargeting::getAbiTargeting).collect(toImmutableSet());
assertThat(abiTargetings).containsExactly(AbiTargeting.getDefaultInstance(), abiTargeting(ARMEABI_V7A));
}
use of com.android.tools.build.bundletool.io.AppBundleSerializer in project bundletool by google.
the class BuildApksPreprocessingTest method buildApksCommand_overridesAssetModuleCompression.
@Test
public void buildApksCommand_overridesAssetModuleCompression() throws Exception {
AppBundle appBundle = new AppBundleBuilder().addModule("base", module -> module.addFile("dex/classes.dex", DUMMY_CONTENT).addFile("assets/images/image.jpg", DUMMY_CONTENT).setManifest(androidManifest("com.test.app", withMinSdkVersion(15), withMaxSdkVersion(27))).setResourceTable(resourceTableWithTestLabel("Test feature"))).addModule("asset_module", module -> module.setManifest(androidManifestForAssetModule("com.test.app", withInstallTimeDelivery())).addFile("assets/textures/texture.etc", DUMMY_CONTENT)).build();
new AppBundleSerializer().writeToDisk(appBundle, bundlePath);
BuildApksCommand command = BuildApksCommand.builder().setBundlePath(bundlePath).setOutputFile(outputFilePath).build();
command.execute();
try (ZipFile apkSetFile = new ZipFile(outputFilePath.toFile())) {
BuildApksResult result = extractTocFromApkSetFile(apkSetFile, outputDir);
// Standalone variant.
ImmutableList<Variant> standaloneVariants = standaloneApkVariants(result);
assertThat(standaloneVariants).hasSize(1);
Variant standaloneVariant = standaloneVariants.get(0);
assertThat(standaloneVariant.getApkSetList()).hasSize(1);
ApkSet standaloneApk = standaloneVariant.getApkSet(0);
assertThat(standaloneApk.getApkDescriptionList()).hasSize(1);
assertThat(apkSetFile).hasFile(standaloneApk.getApkDescription(0).getPath());
File standaloneApkFile = extractFromApkSetFile(apkSetFile, standaloneApk.getApkDescription(0).getPath(), outputDir);
try (ZipFile apkZip = new ZipFile(standaloneApkFile)) {
assertThat(apkZip).hasFile("classes.dex").thatIsCompressed();
assertThat(apkZip).hasFile("assets/images/image.jpg").thatIsCompressed();
assertThat(apkZip).hasFile("assets/textures/texture.etc").thatIsUncompressed();
}
// L+ assets.
assertThat(result.getAssetSliceSetCount()).isEqualTo(1);
AssetSliceSet assetSlice = result.getAssetSliceSet(0);
assertThat(assetSlice.getApkDescriptionCount()).isEqualTo(1);
File apkFile = extractFromApkSetFile(apkSetFile, assetSlice.getApkDescription(0).getPath(), outputDir);
try (ZipFile apkZip = new ZipFile(apkFile)) {
assertThat(apkZip).hasFile("assets/textures/texture.etc").thatIsUncompressed();
}
}
}
Aggregations