use of com.android.tools.build.bundletool.model.AppBundle in project bundletool by google.
the class AddTransparencyCommandTest method createBundle.
private static void createBundle(Path path, boolean hasSharedUserId, int minSdkVersion) throws Exception {
AppBundle appBundle = new AppBundleBuilder().addModule(BASE_MODULE, module -> addCodeFilesToBundleModule(module, hasSharedUserId, minSdkVersion)).addModule(FEATURE_MODULE1, module -> addCodeFilesToBundleModule(module, hasSharedUserId, minSdkVersion)).addModule(FEATURE_MODULE2, module -> addCodeFilesToBundleModule(module, hasSharedUserId, minSdkVersion)).build();
new AppBundleSerializer().writeToDisk(appBundle, path);
}
use of com.android.tools.build.bundletool.model.AppBundle in project bundletool by google.
the class BuildApksConnectedDeviceTest method connectedDevice_universalApk_throws.
@Test
public void connectedDevice_universalApk_throws() throws Exception {
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).setGenerateOnlyForConnectedDevice(true).setApkBuildMode(UNIVERSAL).setAdbPath(sdkDirPath.resolve("platform-tools").resolve("adb")).setAdbServer(fakeAdbServer);
Throwable exception = assertThrows(InvalidCommandException.class, command::build);
assertThat(exception).hasMessageThat().contains("Optimizing for connected device only possible when running with 'default' mode flag.");
}
use of com.android.tools.build.bundletool.model.AppBundle in project bundletool by google.
the class BuildApksConnectedDeviceTest method connectedDevice_noDevicesFound_throws.
@Test
public void connectedDevice_noDevicesFound_throws() throws Exception {
AppBundle appBundle = new AppBundleBuilder().addModule("base", module -> module.setManifest(androidManifest("com.app"))).build();
bundleSerializer.writeToDisk(appBundle, bundlePath);
BuildApksCommand command = BuildApksCommand.builder().setBundlePath(bundlePath).setOutputFile(outputFilePath).setGenerateOnlyForConnectedDevice(true).setAdbPath(sdkDirPath.resolve("platform-tools").resolve("adb")).setAdbServer(fakeAdbServer).build();
Throwable exception = assertThrows(CommandExecutionException.class, () -> command.execute());
assertThat(exception).hasMessageThat().contains("No connected devices found.");
}
use of com.android.tools.build.bundletool.model.AppBundle in project bundletool by google.
the class SplitApksGenerator method generateSplitApks.
private ImmutableList<ModuleSplit> generateSplitApks(ImmutableList<BundleModule> modules, ApkGenerationConfiguration apkGenerationConfiguration, VariantTargeting variantTargeting) {
ImmutableSet<String> allModuleNames = modules.stream().map(module -> module.getName().getName()).collect(toImmutableSet());
ImmutableList.Builder<ModuleSplit> splits = ImmutableList.builder();
for (BundleModule module : modules) {
ModuleSplitter moduleSplitter = ModuleSplitter.create(module, bundletoolVersion, appBundle, apkGenerationConfiguration, variantTargeting, allModuleNames, stampSource.map(SourceStamp::getSource), StampType.STAMP_TYPE_DISTRIBUTION_APK);
splits.addAll(moduleSplitter.splitModule());
}
return splits.build();
}
use of com.android.tools.build.bundletool.model.AppBundle in project bundletool by google.
the class ResourceAnalyzerTest method emptyManifest.
@Test
public void emptyManifest() throws Exception {
XmlNode manifest = androidManifest("com.app");
ResourceTable resourceTable = resourceTable(pkg(0x7f, "com.test.app", type(0x01, "string", entry(0x0099, "not_referenced", value("", DEFAULT_CONFIG)))));
AppBundle appBundle = new AppBundleBuilder().addModule("base", builder -> builder.setManifest(manifest).setResourceTable(resourceTable)).build();
ImmutableSet<ResourceId> resourceIds = new ResourceAnalyzer(appBundle).findAllAppResourcesReachableFromBaseManifest();
assertThat(resourceIds).isEmpty();
}
Aggregations