Search in sources :

Example 6 with SdkBundle

use of com.android.tools.build.bundletool.model.SdkBundle in project bundletool by google.

the class ApkSerializerManager method serializeSdkApkSetContent.

private BuildSdkApksResult serializeSdkApkSetContent(Path outputDirectory, GeneratedApks generatedApks) {
    ImmutableList<Variant> allVariantsWithTargeting = serializeApks(outputDirectory, generatedApks, /* deviceSpec= */
    Optional.empty());
    SdkBundle sdkBundle = (SdkBundle) bundle;
    return BuildSdkApksResult.newBuilder().setPackageName(sdkBundle.getPackageName()).addAllVariant(allVariantsWithTargeting).setBundletool(Bundletool.newBuilder().setVersion(BundleToolVersion.getCurrentVersion().toString())).setVersion(SdkVersionInformation.newBuilder().setVersionCode(sdkBundle.getVersionCode()).setMajor(Long.parseLong(sdkBundle.getMajorVersion())).setPatch(Long.parseLong(sdkBundle.getPatchVersion())).build()).build();
}
Also used : Variant(com.android.bundle.Commands.Variant) SdkBundle(com.android.tools.build.bundletool.model.SdkBundle)

Example 7 with SdkBundle

use of com.android.tools.build.bundletool.model.SdkBundle in project bundletool by google.

the class BuildSdkApksManagerTest method sdkManifestMutation_patchVersionNotSet_defaultPatchVersionAdded.

@Test
public void sdkManifestMutation_patchVersionNotSet_defaultPatchVersionAdded() throws Exception {
    SdkBundle sdkBundle = new SdkBundleBuilder().setModule(new BundleModuleBuilder("base").setManifest(androidManifest(PACKAGE_NAME, withSdkLibraryElement("20"))).build()).build();
    execute(sdkBundle);
    ZipFile apkSetFile = new ZipFile(outputFilePath.toFile());
    BuildSdkApksResult result = extractTocFromSdkApkSetFile(apkSetFile, tmpDir);
    Variant variant = result.getVariant(0);
    ApkDescription apkDescription = variant.getApkSet(0).getApkDescription(0);
    File apkFile = extractFromApkSetFile(apkSetFile, apkDescription.getPath(), tmpDir);
    AndroidManifest manifest = extractAndroidManifest(apkFile, tmpDir);
    assertThat(manifest.getMetadataValue(SDK_PATCH_VERSION_ATTRIBUTE_NAME)).hasValue(DEFAULT_SDK_PATCH_VERSION);
}
Also used : BuildSdkApksResult(com.android.bundle.Commands.BuildSdkApksResult) Variant(com.android.bundle.Commands.Variant) ApkDescription(com.android.bundle.Commands.ApkDescription) ZipFile(java.util.zip.ZipFile) BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) SdkBundle(com.android.tools.build.bundletool.model.SdkBundle) AndroidManifest(com.android.tools.build.bundletool.model.AndroidManifest) TestUtils.extractAndroidManifest(com.android.tools.build.bundletool.testing.TestUtils.extractAndroidManifest) SdkBundleBuilder(com.android.tools.build.bundletool.testing.SdkBundleBuilder) ApkSetUtils.extractTocFromSdkApkSetFile(com.android.tools.build.bundletool.testing.ApkSetUtils.extractTocFromSdkApkSetFile) ZipFile(java.util.zip.ZipFile) File(java.io.File) ApkSetUtils.extractFromApkSetFile(com.android.tools.build.bundletool.testing.ApkSetUtils.extractFromApkSetFile) Test(org.junit.Test)

Aggregations

SdkBundle (com.android.tools.build.bundletool.model.SdkBundle)7 ZipFile (java.util.zip.ZipFile)6 BuildSdkApksResult (com.android.bundle.Commands.BuildSdkApksResult)4 BundleModuleBuilder (com.android.tools.build.bundletool.testing.BundleModuleBuilder)4 SdkBundleBuilder (com.android.tools.build.bundletool.testing.SdkBundleBuilder)4 Test (org.junit.Test)4 Variant (com.android.bundle.Commands.Variant)3 File (java.io.File)3 ApkDescription (com.android.bundle.Commands.ApkDescription)2 SdkVersionInformation (com.android.bundle.Commands.SdkVersionInformation)2 TempDirectory (com.android.tools.build.bundletool.io.TempDirectory)2 ZipReader (com.android.tools.build.bundletool.io.ZipReader)2 AndroidManifest (com.android.tools.build.bundletool.model.AndroidManifest)2 SdkBundleValidator (com.android.tools.build.bundletool.validation.SdkBundleValidator)2 IOException (java.io.IOException)2 UncheckedIOException (java.io.UncheckedIOException)2 ZipException (java.util.zip.ZipException)2 SigningCertificateLineage (com.android.apksig.SigningCertificateLineage)1 ApkFormatException (com.android.apksig.apk.ApkFormatException)1 DataSource (com.android.apksig.util.DataSource)1