use of com.android.tools.build.bundletool.optimizations.ApkOptimizations in project bundletool by google.
the class SystemApksGeneratorTest method uncompressedDexFiles_enabled.
@Test
public void uncompressedDexFiles_enabled() throws Exception {
BundleModule baseModule = new BundleModuleBuilder("base").addFile("dex/classes.dex").setManifest(androidManifestForFeature("com.test.app")).build();
ApkOptimizations apkOptimizations = splitOptimizations().toBuilder().setUncompressDexFiles(true).build();
ImmutableList<ModuleSplit> shards = systemApksGenerator.generateSystemApks(/* modules= */
ImmutableList.of(baseModule), /* modulesToFuse= */
ImmutableSet.of(BASE_MODULE_NAME), apkOptimizations);
assertThat(shards).hasSize(1);
ModuleSplit fatApk = shards.get(0);
assertThat(fatApk.findEntry("dex/classes.dex").map(ModuleEntry::getForceUncompressed)).hasValue(true);
}
use of com.android.tools.build.bundletool.optimizations.ApkOptimizations in project bundletool by google.
the class SystemApksGeneratorTest method uncompressedNativeLibraries_enabled_singleApk.
@Test
public void uncompressedNativeLibraries_enabled_singleApk() throws Exception {
BundleModule baseModule = new BundleModuleBuilder("base").addFile("assets/images/img.png").addFile("res/layout/default.xml").addFile("lib/x86_64/libtest1.so").addFile("lib/x86/libtest1.so").setResourceTable(new ResourceTableBuilder().addPackage("com.test.app").addFileResource("layout", "default", "res/layout/default.xml").build()).setNativeConfig(nativeLibraries(targetedNativeDirectory("lib/x86_64", nativeDirectoryTargeting(X86_64)), targetedNativeDirectory("lib/x86", nativeDirectoryTargeting(X86)))).setManifest(androidManifestForFeature("com.test.app")).build();
BundleModule featureModule = new BundleModuleBuilder("feature").addFile("lib/x86_64/libtest2.so").addFile("lib/x86/libtest2.so").setNativeConfig(nativeLibraries(targetedNativeDirectory("lib/x86_64", nativeDirectoryTargeting(X86_64)), targetedNativeDirectory("lib/x86", nativeDirectoryTargeting(X86)))).setManifest(androidManifestForFeature("com.test.app.feature")).build();
ApkOptimizations apkOptimizations = splitOptimizations(OptimizationDimension.ABI).toBuilder().setUncompressNativeLibraries(true).build();
ImmutableList<ModuleSplit> shards = systemApksGenerator.generateSystemApks(/* modules= */
ImmutableList.of(baseModule, featureModule), /* modulesToFuse= */
ImmutableSet.of(BASE_MODULE_NAME, FEATURE_MODULE_NAME), apkOptimizations);
assertThat(shards).hasSize(1);
ModuleSplit fatApk = shards.get(0);
assertThat(fatApk.getAndroidManifest().getExtractNativeLibsValue()).hasValue(false);
assertThat(fatApk.findEntry("lib/x86/libtest1.so").map(ModuleEntry::getForceUncompressed)).hasValue(true);
assertThat(fatApk.findEntry("lib/x86/libtest2.so").map(ModuleEntry::getForceUncompressed)).hasValue(true);
assertThat(fatApk.findEntry("res/layout/default.xml").map(ModuleEntry::getForceUncompressed)).hasValue(false);
assertThat(fatApk.findEntry("assets/images/img.png").map(ModuleEntry::getForceUncompressed)).hasValue(false);
assertThat(fatApk.findEntry("lib/x86_64/libtest1.so")).isEmpty();
}
use of com.android.tools.build.bundletool.optimizations.ApkOptimizations in project bundletool by google.
the class SystemApksGeneratorTest method uncompressedNativeLibraries_enabled_multiApks.
@Test
public void uncompressedNativeLibraries_enabled_multiApks() throws Exception {
BundleModule baseModule = new BundleModuleBuilder("base").addFile("lib/x86_64/libtest1.so").addFile("lib/x86/libtest1.so").setNativeConfig(nativeLibraries(targetedNativeDirectory("lib/x86_64", nativeDirectoryTargeting(X86_64)), targetedNativeDirectory("lib/x86", nativeDirectoryTargeting(X86)))).setManifest(androidManifestForFeature("com.test.app")).build();
BundleModule featureModule = new BundleModuleBuilder("feature").addFile("lib/x86_64/libtest2.so").addFile("lib/x86/libtest2.so").setNativeConfig(nativeLibraries(targetedNativeDirectory("lib/x86_64", nativeDirectoryTargeting(X86_64)), targetedNativeDirectory("lib/x86", nativeDirectoryTargeting(X86)))).setManifest(androidManifestForFeature("com.test.app.feature")).build();
ApkOptimizations apkOptimizations = splitOptimizations(OptimizationDimension.ABI).toBuilder().setUncompressNativeLibraries(true).build();
ImmutableList<ModuleSplit> shards = systemApksGenerator.generateSystemApks(/* modules= */
ImmutableList.of(baseModule, featureModule), /* modulesToFuse= */
ImmutableSet.of(BASE_MODULE_NAME), apkOptimizations);
assertThat(shards).hasSize(3);
ModuleSplit systemApk = getSystemImageSplit(shards);
assertThat(systemApk.getAndroidManifest().getExtractNativeLibsValue()).hasValue(false);
assertThat(systemApk.findEntry("lib/x86/libtest1.so").map(ModuleEntry::getForceUncompressed)).hasValue(true);
ModuleSplit additionalNativeSplit = getAdditionalSplits(shards).stream().filter(split -> split.getApkTargeting().hasAbiTargeting()).collect(onlyElement());
assertThat(additionalNativeSplit.findEntry("lib/x86/libtest2.so").map(ModuleEntry::getForceUncompressed)).hasValue(true);
}
use of com.android.tools.build.bundletool.optimizations.ApkOptimizations in project bundletool by google.
the class SystemApksGeneratorTest method uncompressedNativeLibraries_disabled.
@Test
public void uncompressedNativeLibraries_disabled() throws Exception {
BundleModule baseModule = new BundleModuleBuilder("base").addFile("lib/x86_64/libtest1.so").addFile("lib/x86/libtest1.so").setNativeConfig(nativeLibraries(targetedNativeDirectory("lib/x86_64", nativeDirectoryTargeting(X86_64)), targetedNativeDirectory("lib/x86", nativeDirectoryTargeting(X86)))).setManifest(androidManifestForFeature("com.test.app")).build();
ApkOptimizations apkOptimizations = splitOptimizations(OptimizationDimension.ABI).toBuilder().setUncompressNativeLibraries(false).build();
ImmutableList<ModuleSplit> shards = systemApksGenerator.generateSystemApks(/* modules= */
ImmutableList.of(baseModule), /* modulesToFuse= */
ImmutableSet.of(BASE_MODULE_NAME), apkOptimizations);
assertThat(shards).hasSize(1);
ModuleSplit fatApk = shards.get(0);
assertThat(fatApk.getAndroidManifest().getExtractNativeLibsValue()).isEmpty();
assertThat(fatApk.findEntry("lib/x86/libtest1.so").map(ModuleEntry::getForceUncompressed)).hasValue(false);
assertThat(fatApk.findEntry("lib/x86_64/libtest1.so")).isEmpty();
}
use of com.android.tools.build.bundletool.optimizations.ApkOptimizations in project bundletool by google.
the class SystemApksGeneratorTest method uncompressedDexFiles_disabled.
@Test
public void uncompressedDexFiles_disabled() throws Exception {
BundleModule baseModule = new BundleModuleBuilder("base").addFile("dex/classes.dex").setManifest(androidManifestForFeature("com.test.app")).build();
ApkOptimizations apkOptimizations = splitOptimizations().toBuilder().setUncompressDexFiles(false).build();
ImmutableList<ModuleSplit> shards = systemApksGenerator.generateSystemApks(/* modules= */
ImmutableList.of(baseModule), /* modulesToFuse= */
ImmutableSet.of(BASE_MODULE_NAME), apkOptimizations);
assertThat(shards).hasSize(1);
ModuleSplit fatApk = shards.get(0);
assertThat(fatApk.findEntry("dex/classes.dex").map(ModuleEntry::getForceUncompressed)).hasValue(false);
}
Aggregations