Search in sources :

Example 1 with BuildApksCommand

use of com.android.tools.build.bundletool.commands.BuildApksCommand in project bundletool by google.

the class BuildExtractApksTest method forLDeviceUniversalApk.

@Test
public void forLDeviceUniversalApk() throws Exception {
    AppBundle appBundle = createAppBundle();
    bundleSerializer.writeToDisk(appBundle, bundlePath);
    BuildApksCommand command = BuildApksCommand.builder().setBundlePath(bundlePath).setOutputFile(outputFilePath).setAapt2Command(aapt2Command).setApkBuildMode(UNIVERSAL).build();
    Path apkSetFilePath = command.execute();
    ExtractApksCommand extractApksCommand = ExtractApksCommand.builder().setOutputDirectory(outputDir).setApksArchivePath(apkSetFilePath).setDeviceSpec(L_X86_64_ES_DEVICE).build();
    ImmutableList<Path> extractedApks = extractApksCommand.execute();
    assertThat(extractedApks.stream().map(Path::getFileName).map(Path::toString).collect(toImmutableList())).containsExactly("universal.apk");
}
Also used : Path(java.nio.file.Path) AppBundle(com.android.tools.build.bundletool.model.AppBundle) ExtractApksCommand(com.android.tools.build.bundletool.commands.ExtractApksCommand) BuildApksCommand(com.android.tools.build.bundletool.commands.BuildApksCommand) Test(org.junit.Test)

Example 2 with BuildApksCommand

use of com.android.tools.build.bundletool.commands.BuildApksCommand in project bundletool by google.

the class BuildExtractApksTest method forPreLDeviceUniversalApk.

@Test
public void forPreLDeviceUniversalApk() throws Exception {
    AppBundle appBundle = createAppBundle();
    bundleSerializer.writeToDisk(appBundle, bundlePath);
    BuildApksCommand command = BuildApksCommand.builder().setBundlePath(bundlePath).setOutputFile(outputFilePath).setAapt2Command(aapt2Command).setApkBuildMode(UNIVERSAL).build();
    Path apkSetFilePath = command.execute();
    ExtractApksCommand extractApksCommand = ExtractApksCommand.builder().setOutputDirectory(outputDir).setApksArchivePath(apkSetFilePath).setDeviceSpec(PRE_L_X86_ES_DEVICE).build();
    ImmutableList<Path> extractedApks = extractApksCommand.execute();
    assertThat(extractedApks.stream().map(Path::getFileName).map(Path::toString).collect(toImmutableList())).containsExactly("universal.apk");
}
Also used : Path(java.nio.file.Path) AppBundle(com.android.tools.build.bundletool.model.AppBundle) ExtractApksCommand(com.android.tools.build.bundletool.commands.ExtractApksCommand) BuildApksCommand(com.android.tools.build.bundletool.commands.BuildApksCommand) Test(org.junit.Test)

Example 3 with BuildApksCommand

use of com.android.tools.build.bundletool.commands.BuildApksCommand in project bundletool by google.

the class BuildExtractApksTest method forLDevice.

@Test
public void forLDevice() throws Exception {
    AppBundle appBundle = createAppBundle();
    bundleSerializer.writeToDisk(appBundle, bundlePath);
    BuildApksCommand command = BuildApksCommand.builder().setBundlePath(bundlePath).setOutputFile(outputFilePath).setAapt2Command(aapt2Command).build();
    Path apkSetFilePath = command.execute();
    ExtractApksCommand extractApksCommand = ExtractApksCommand.builder().setOutputDirectory(outputDir).setApksArchivePath(apkSetFilePath).setDeviceSpec(L_X86_64_ES_DEVICE).build();
    ImmutableList<String> extractedApks = extractApksCommand.execute().stream().map(Path::getFileName).map(Path::toString).collect(toImmutableList());
    assertThat(extractedApks).hasSize(4);
    assertThat(extractedApks).containsAtLeast("base-xhdpi.apk", "base-es.apk");
    assertThat(extractedApks).containsAnyOf("base-master.apk", "base-master_2.apk");
    assertThat(extractedApks).containsAnyOf("base-x86_64.apk", "base-x86_64_2.apk");
}
Also used : Path(java.nio.file.Path) AppBundle(com.android.tools.build.bundletool.model.AppBundle) ExtractApksCommand(com.android.tools.build.bundletool.commands.ExtractApksCommand) BuildApksCommand(com.android.tools.build.bundletool.commands.BuildApksCommand) Test(org.junit.Test)

Example 4 with BuildApksCommand

use of com.android.tools.build.bundletool.commands.BuildApksCommand in project bundletool by google.

the class BuildExtractApksTest method forPreLDevice.

@Test
public void forPreLDevice() throws Exception {
    AppBundle appBundle = createAppBundle();
    bundleSerializer.writeToDisk(appBundle, bundlePath);
    BuildApksCommand command = BuildApksCommand.builder().setBundlePath(bundlePath).setOutputFile(outputFilePath).setAapt2Command(aapt2Command).build();
    Path apkSetFilePath = command.execute();
    ExtractApksCommand extractApksCommand = ExtractApksCommand.builder().setOutputDirectory(outputDir).setApksArchivePath(apkSetFilePath).setDeviceSpec(PRE_L_X86_ES_DEVICE).build();
    ImmutableList<Path> extractedApks = extractApksCommand.execute();
    assertThat(extractedApks.stream().map(Path::getFileName).map(Path::toString).collect(toImmutableList())).containsExactly("standalone-x86_hdpi.apk");
}
Also used : Path(java.nio.file.Path) AppBundle(com.android.tools.build.bundletool.model.AppBundle) ExtractApksCommand(com.android.tools.build.bundletool.commands.ExtractApksCommand) BuildApksCommand(com.android.tools.build.bundletool.commands.BuildApksCommand) Test(org.junit.Test)

Aggregations

BuildApksCommand (com.android.tools.build.bundletool.commands.BuildApksCommand)4 ExtractApksCommand (com.android.tools.build.bundletool.commands.ExtractApksCommand)4 AppBundle (com.android.tools.build.bundletool.model.AppBundle)4 Path (java.nio.file.Path)4 Test (org.junit.Test)4