简体   繁体   English

未解决的参考:android build failed with kotlin dsl(可在空项目中重现)

[英]unresolved reference: android build failed with kotlin dsl (reproducible in an empty project)

My build.gradle.kts(:app) :我的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")
}

My other build.gradle.kts (Top 10 Downloader):我的另一个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)
}

my settings.gradle.kts :我的settings.gradle.kts

include (":app")
rootProject.name="Top 10 Downloader"

It is reproducible in an empty project.它可以在空项目中重现。 I'm using latest canary android studio arctic fox.我正在使用最新的金丝雀 android 工作室北极狐。 What I am doing wrong?我做错了什么?

ok bug found.好的错误发现。 Latest canary android studio updated my gradle version and because of gradle update, buildFeatures { compose = true } in build.gradle causes gradle to run forever because i was using kotlin synthetics which is now deprecated. Latest canary android studio updated my gradle version and because of gradle update, buildFeatures { compose = true } in build.gradle causes gradle to run forever because i was using kotlin synthetics which is now deprecated. So in latest gradle (7), USING synthetics (not just adding) and IMPORTING buildFeatures { compose = true } causes gradle infinite loop.所以在最新的 gradle (7) 中,使用合成(不仅仅是添加)和 IMPORTING buildFeatures { compose = true }会导致 gradle 无限循环。

I was able to resolve this error by disabling gradle offline mode .我能够通过禁用 gradle 离线模式来解决此错误。 如何禁用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM