- In the test project link, we have
- app: the base application
- dynamicfeature: the dynamic feature module
- mylibrary: the kotlin library
- В dynamicfeature < /strong> build.gradle.kts < /li>
< /ul>Проблема: [/b]Код: Выделить всё
dependencies { implementation(project(":app")) ... < /code> В app < /strong> build.gradle.kts < /li> < /ul> android { dynamicFeatures += setOf(":dynamicfeature") ... } tasks.register("writeVersionSuffix") { doLast { var versionSuffix = getUnifiedVersionSuffix(1234) println("writeVersionSuffix versionSuffix: ${versionSuffix}") var versionSuffixFile = file("${buildDir}/outputs/versionSuffix.txt") versionSuffixFile.writeText(versionSuffix) } } tasks.register("cleanOriginArtifacts") { doLast { } } fun getUnifiedVersionSuffix(number: Any?): String { val versionName = android.defaultConfig.versionName val versionParts = versionName?.split(".")?: listOf("1", "0") val majorMinorVersion = if (versionParts.size < 2) "${versionParts[0]}.0" else "${versionParts[0]}.${versionParts[1]}" val validNumber = number ?: "000" val suffix = "${majorMinorVersion}.${validNumber}" return suffix } tasks.register("standardizeArtifactsNames") { doLast { copy { val outDir = "${buildDir}/outputs" val versionSuffix = getUnifiedVersionSuffix(1234) into(outDir) println("standardizeArtifactsNames outputDir: $outDir, versionSuffix: $versionSuffix") into("apk_from_bundle/release") { duplicatesStrategy = DuplicatesStrategy.INCLUDE from("${outDir}/apk_from_bundle/release") rename("app-release-universal.apk", "app_release_universal_${versionSuffix}.apk") } into("bundle/release") { duplicatesStrategy = DuplicatesStrategy.INCLUDE from("${outDir}/bundle/release") rename("app-release.aab", "app_release_${versionSuffix}.aab") } into("mapping/release") { duplicatesStrategy = DuplicatesStrategy.INCLUDE from("${outDir}/mapping/release") rename("mapping.txt", "mapping_${versionSuffix}.txt") } } } } tasks.register("publishRelease", GradleBuild::class) { doFirst { println("=============== core build publishRelease start ===============") } dependsOn("clean") setTasks(listOf("bundleRelease", "packageReleaseUniversalApk", "standardizeArtifactsNames", "writeVersionSuffix", "cleanOriginArtifacts")) doLast { println("=============== core build publishRelease finish ===============") } } dependencies { implementation(project(":mylibrary")) implementation(libs.androidx.core.ktx) ... }
./gradlew publishRelease
Я получил проблему R8
Код: Выделить всё
> Task :app:app:minifyReleaseWithR8 FAILED
ERROR: /Users/*/Documents/GitHub/MyApplication2/app/build/intermediates/module_and_runtime_deps_classes/release/mergeReleaseClasses/base.jar: R8: Type com.example.myapplication.MainBlankFragmentKt **is defined multiple times**: /Users/*/Documents/GitHub/MyApplication2/app/build/intermediates/module_and_runtime_deps_classes/release/mergeReleaseClasses/base.jar:com/example/myapplication/MainBlankFragmentKt.class, /Users/*/Documents/GitHub/MyApplication2/dynamicfeature/build/intermediates/module_and_runtime_deps_classes/release/mergeReleaseClasses/feature-dynamicfeature.jar:com/example/myapplication/MainBlankFragmentKt.class
< /code>
Если я смутил код линии // реализация (Project (": app")), то < /p>
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:dynamicfeature:processReleaseNavigationResources'.
> Error while evaluating property 'applicationId' of task ':app:dynamicfeature:processReleaseNavigationResources'.
> Failed to calculate the value of task ':app:dynamicfeature:processReleaseNavigationResources' property 'applicationId'.
> Failed to calculate the value of property 'applicationId'.
> Collection is empty.
, а также ниже темы, упомянутой. не должно иметь этого. Я новичок для Android Kotlin, вы бы помогли в этом?
Подробнее здесь: https://stackoverflow.com/questions/797 ... ic-feature