未解决的参考:android 使用 kotlin dsl 构建失败(可在空项目中重现)
unresolved reference: android build failed with kotlin dsl (reproducible in an empty project)
我的build.gradle.kts(:app)
:
plugins {
id("com.android.application")
kotlin("plugin.serialization") version "1.4.21-release-Studio4.2-1"
kotlin("android")
kotlin("android.extensions")
kotlin("kapt")
}
android {
compileSdkVersion (30)
buildToolsVersion ("30.0.2")
defaultConfig {
applicationId ="learnprogramming.academy.relaf"
minSdkVersion(24)
targetSdkVersion(30)
versionCode =1
versionName ="1.0"
testInstrumentationRunner ="androidx.test.runner.AndroidJUnitRunner"
javaCompileOptions {
annotationProcessorOptions {
arguments["room.incremental"] = "true"
}
}
}
buildTypes {
getByName("release") {
isMinifyEnabled = true
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
}
}
buildFeatures {
// Enables Jetpack Compose for this module
compose = true
}
compileOptions {
sourceCompatibility= JavaVersion.VERSION_1_8
targetCompatibility= JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
useIR = true
}
composeOptions {
kotlinCompilerVersion= "1.4.21-release-Studio4.2-1"
kotlinCompilerExtensionVersion= "1.0.0-alpha08"
}
}
dependencies {
val composeVersion = "1.0.0-alpha08"
// implementation ("androidx.compose.runtime:runtime:$composeVersion")
// implementation ("androidx.compose.compiler:compiler:$composeVersion")
// implementation ("androidx.compose.ui:ui:$composeVersion")
// Tooling support (Previews, etc.)
implementation ("androidx.compose.ui:ui-tooling:$composeVersion")
// Foundation (Border, Background, Box, Image, Scroll, shapes, animations, etc.)
implementation ("androidx.compose.foundation:foundation:$composeVersion")
// Material Design
implementation ("androidx.compose.material:material:$composeVersion")
// Material design icons
implementation ("androidx.compose.material:material-icons-core:$composeVersion")
implementation ("androidx.compose.material:material-icons-extended:$composeVersion")
// Integration with observables
implementation ("androidx.compose.runtime:runtime-livedata:$composeVersion")
val roomVersion = "2.3.0-alpha04"
implementation( "androidx.room:room-runtime:$roomVersion")
kapt ("androidx.room:room-compiler:$roomVersion")
val kotlin_version = "1.4.21"
implementation ("org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version")
implementation( "androidx.appcompat:appcompat:1.3.0-alpha02")
testImplementation ("junit:junit:4.12")
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
// optional - Kotlin Extensions and Coroutines support for Room
implementation ("androidx.room:room-ktx:$roomVersion")
// ViewModel and LiveData
val lifecycle_version = "2.2.0"
implementation ("androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version")
implementation ("androidx.lifecycle:lifecycle-extensions:$lifecycle_version")
implementation ("androidx.fragment:fragment-ktx:1.2.2")
// RecyclerView
implementation ("androidx.recyclerview:recyclerview:1.0.0")
implementation ("com.google.android.material:material:1.3.0-alpha03")
implementation ("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9")
implementation ("com.android.volley:volley:1.1.1")
implementation("org.jsoup:jsoup:1.13.1")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.1")
implementation ("androidx.core:core-ktx:1.0.2")
implementation ("androidx.constraintlayout:constraintlayout:1.1.3")
androidTestImplementation ("androidx.test.ext:junit:1.1.0")
androidTestImplementation( "androidx.test.espresso:espresso-core:3.1.1")
}
我的其他 build.gradle.kts
(前 10 名下载者):
buildscript {
val kotlin_version = "1.4.21"
repositories {
google()
jcenter()
}
dependencies {
classpath ("com.android.tools.build:gradle:7.0.0-alpha03")
classpath ("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
tasks.register("clean",Delete::class){
delete(rootProject.buildDir)
}
我的settings.gradle.kts
:
include (":app")
rootProject.name="Top 10 Downloader"
它可以在一个空项目中重现。我正在使用最新的 canary android studio arctic fox。我做错了什么?
确定发现错误。最新的金丝雀 android 工作室更新了我的 gradle 版本,由于 gradle 更新,build.gradle 中的 buildFeatures { compose = true }
导致 gradle 永远 运行因为我使用的是现在已弃用的 kotlin 合成材料。所以在最新的 gradle (7) 中,使用合成(不仅仅是添加)和导入 buildFeatures { compose = true }
导致 gradle 无限循环。
我能够通过禁用gradle离线模式解决这个错误。
我的build.gradle.kts(:app)
:
plugins {
id("com.android.application")
kotlin("plugin.serialization") version "1.4.21-release-Studio4.2-1"
kotlin("android")
kotlin("android.extensions")
kotlin("kapt")
}
android {
compileSdkVersion (30)
buildToolsVersion ("30.0.2")
defaultConfig {
applicationId ="learnprogramming.academy.relaf"
minSdkVersion(24)
targetSdkVersion(30)
versionCode =1
versionName ="1.0"
testInstrumentationRunner ="androidx.test.runner.AndroidJUnitRunner"
javaCompileOptions {
annotationProcessorOptions {
arguments["room.incremental"] = "true"
}
}
}
buildTypes {
getByName("release") {
isMinifyEnabled = true
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
}
}
buildFeatures {
// Enables Jetpack Compose for this module
compose = true
}
compileOptions {
sourceCompatibility= JavaVersion.VERSION_1_8
targetCompatibility= JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
useIR = true
}
composeOptions {
kotlinCompilerVersion= "1.4.21-release-Studio4.2-1"
kotlinCompilerExtensionVersion= "1.0.0-alpha08"
}
}
dependencies {
val composeVersion = "1.0.0-alpha08"
// implementation ("androidx.compose.runtime:runtime:$composeVersion")
// implementation ("androidx.compose.compiler:compiler:$composeVersion")
// implementation ("androidx.compose.ui:ui:$composeVersion")
// Tooling support (Previews, etc.)
implementation ("androidx.compose.ui:ui-tooling:$composeVersion")
// Foundation (Border, Background, Box, Image, Scroll, shapes, animations, etc.)
implementation ("androidx.compose.foundation:foundation:$composeVersion")
// Material Design
implementation ("androidx.compose.material:material:$composeVersion")
// Material design icons
implementation ("androidx.compose.material:material-icons-core:$composeVersion")
implementation ("androidx.compose.material:material-icons-extended:$composeVersion")
// Integration with observables
implementation ("androidx.compose.runtime:runtime-livedata:$composeVersion")
val roomVersion = "2.3.0-alpha04"
implementation( "androidx.room:room-runtime:$roomVersion")
kapt ("androidx.room:room-compiler:$roomVersion")
val kotlin_version = "1.4.21"
implementation ("org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version")
implementation( "androidx.appcompat:appcompat:1.3.0-alpha02")
testImplementation ("junit:junit:4.12")
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
// optional - Kotlin Extensions and Coroutines support for Room
implementation ("androidx.room:room-ktx:$roomVersion")
// ViewModel and LiveData
val lifecycle_version = "2.2.0"
implementation ("androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version")
implementation ("androidx.lifecycle:lifecycle-extensions:$lifecycle_version")
implementation ("androidx.fragment:fragment-ktx:1.2.2")
// RecyclerView
implementation ("androidx.recyclerview:recyclerview:1.0.0")
implementation ("com.google.android.material:material:1.3.0-alpha03")
implementation ("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9")
implementation ("com.android.volley:volley:1.1.1")
implementation("org.jsoup:jsoup:1.13.1")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.1")
implementation ("androidx.core:core-ktx:1.0.2")
implementation ("androidx.constraintlayout:constraintlayout:1.1.3")
androidTestImplementation ("androidx.test.ext:junit:1.1.0")
androidTestImplementation( "androidx.test.espresso:espresso-core:3.1.1")
}
我的其他 build.gradle.kts
(前 10 名下载者):
buildscript {
val kotlin_version = "1.4.21"
repositories {
google()
jcenter()
}
dependencies {
classpath ("com.android.tools.build:gradle:7.0.0-alpha03")
classpath ("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
tasks.register("clean",Delete::class){
delete(rootProject.buildDir)
}
我的settings.gradle.kts
:
include (":app")
rootProject.name="Top 10 Downloader"
它可以在一个空项目中重现。我正在使用最新的 canary android studio arctic fox。我做错了什么?
确定发现错误。最新的金丝雀 android 工作室更新了我的 gradle 版本,由于 gradle 更新,build.gradle 中的 buildFeatures { compose = true }
导致 gradle 永远 运行因为我使用的是现在已弃用的 kotlin 合成材料。所以在最新的 gradle (7) 中,使用合成(不仅仅是添加)和导入 buildFeatures { compose = true }
导致 gradle 无限循环。
我能够通过禁用gradle离线模式解决这个错误。