1- import com.android.build.gradle.api.ApkVariantOutput
2- import com.android.build.gradle.api.ApplicationVariant
3- import com.android.build.gradle.api.BaseVariantOutput
4-
51/*
62 * Copyright 2020 Google LLC.
73 *
@@ -24,11 +20,11 @@ plugins {
2420}
2521
2622android {
27- compileSdkVersion( 29 )
23+ compileSdk = 30
2824 defaultConfig {
2925 applicationId = " com.google.android.samples.dynamicnavigator"
30- minSdkVersion( 21 )
31- targetSdkVersion( 29 )
26+ minSdk = 21
27+ targetSdk = 30
3228 versionCode = 3
3329 versionName = " 1.0"
3430 testInstrumentationRunner = " androidx.test.runner.AndroidJUnitRunner"
@@ -41,55 +37,19 @@ android {
4137 }
4238
4339 compileOptions {
44- sourceCompatibility = JavaVersion .VERSION_1_8
45- targetCompatibility = JavaVersion .VERSION_1_8
40+ sourceCompatibility = JavaVersion .VERSION_11
41+ targetCompatibility = JavaVersion .VERSION_11
4642 }
4743
48- dynamicFeatures = mutableSetOf ( " :dynamicfeature" , " :includedgraphfeature" )
44+ dynamicFeatures.addAll( setOf ( " :dynamicfeature" , " :includedgraphfeature" ) )
4945
5046 packagingOptions {
51- exclude (" META-INF/**.version" )
47+ resources.excludes.add (" META-INF/**.version" )
5248 }
5349}
5450
5551dependencies {
56- api(" androidx.navigation:navigation-dynamic-features-fragment:2.3.0" )
57- api(" androidx.appcompat:appcompat:1.1.0" )
58- api(" androidx.constraintlayout:constraintlayout:1.1.3" )
59- }
60-
61- val bundletoolJar = project.rootDir.resolve(" third_party/bundletool/bundletool-all-0.13.0.jar" )
62-
63- android.applicationVariants.all(object : Action <ApplicationVariant > {
64- override fun execute (variant : ApplicationVariant ) {
65- variant.outputs.forEach { output: BaseVariantOutput ? ->
66- (output as ? ApkVariantOutput )?.let { apkOutput: ApkVariantOutput ->
67- var filePath = apkOutput.outputFile.absolutePath
68- filePath = filePath.replaceAfterLast(" ." , " aab" )
69- filePath = filePath.replace(" build/outputs/apk/" , " build/outputs/bundle/" )
70- var outputPath = filePath.replace(" build/outputs/bundle/" , " build/outputs/apks/" )
71- outputPath = outputPath.replaceAfterLast(" ." , " apks" )
72-
73- tasks.register<JavaExec >(" buildApks${variant.name.capitalize()} " ) {
74- classpath = files(bundletoolJar)
75- args = listOf (
76- " build-apks" ,
77- " --overwrite" ,
78- " --local-testing" ,
79- " --bundle" ,
80- filePath,
81- " --output" ,
82- outputPath
83- )
84- dependsOn(" bundle${variant.name.capitalize()} " )
85- }
86-
87- tasks.register<JavaExec >(" installApkSplitsForTest${variant.name.capitalize()} " ) {
88- classpath = files(bundletoolJar)
89- args = listOf (" install-apks" , " --apks" , outputPath)
90- dependsOn(" buildApks${variant.name.capitalize()} " )
91- }
92- }
93- }
94- }
95- })
52+ api(" androidx.navigation:navigation-dynamic-features-fragment:2.4.0-alpha01" )
53+ api(" androidx.appcompat:appcompat:1.3.0" )
54+ api(" androidx.constraintlayout:constraintlayout:2.0.4" )
55+ }
0 commit comments