我正在使用 Android Studio 与 Kotlin 进行 Android 开发。我的项目中有40多个Android模块:其中一些是Java模块,一些主题是android模块。
Kotlin Version = "1.8.20"
Hilt Version = "2.45"
Compose BOM Version = "2023.01.00"
Compose Compiler Version = "1.4.3"
com.android.library = "7.4.1"
com.android.application = "7.4.1"
我想运行 Compose Metrics 考虑以下因素:
buildscript {
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.4.1' apply false
id 'com.android.library' version '7.4.1' apply false
id 'org.jetbrains.kotlin.android' version '1.8.10' apply false
id 'com.google.dagger.hilt.android' version '2.45' apply false
}
subprojects {
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
if (project.findProperty("myapp.enableComposeCompilerReports") == "true") {
freeCompilerArgs += [
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=" +
project.buildDir.absolutePath + "/compose_metrics"
]
freeCompilerArgs += [
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=" +
project.buildDir.absolutePath + "/compose_metrics"
]
}
}
}
}
但我看到一个错误,如下所示:
Multiple values are not allowed for plugin option androidx.compose.compiler.plugins.kotlin:reportsDestination
Plugin "androidx.compose.compiler.plugins.kotlin" usage:
liveLiterals <true|false> Enable Live Literals code generation
liveLiteralsEnabled <true|false>
Enable Live Literals code generation (with per-file enabled flags)
generateFunctionKeyMetaClasses <true|false>
Generate function key meta classes with annotations indicating the functions and their group keys. Generally used for tooling.
sourceInformation <true|false>
Include source information in generated code
metricsDestination <path> Save compose build metrics to this folder
reportsDestination <path> Save compose build reports to this folder
intrinsicRemember <true|false>
Include source information in generated code
suppressKotlinVersionCompatibilityCheck <true|false>
Suppress Kotlin version compatibility check
generateDecoys <true|false>
Generate decoy methods in IR transform
在另一个简单的项目中,当我添加 Hilt 时出现了这个问题
Update:
如果您添加 kapt 插件,您将遇到此问题。
Add id 'org.jetbrains.kotlin.kapt' version '1.8.10' apply false
到顶层 build.gradle
添加id 'org.jetbrains.kotlin.kapt'
到应用程序的 build.gradle
Run ./gradlew assembleDebug -Pmyapp.enableComposeCompilerReports=true
并且该问题将在不添加任何 Hilt 依赖项的情况下重现。
Update:
如果您将 gradle 文件迁移到 kts 并(使用版本目录和插件约定)。我认为你的问题会得到解决