更新Android Studio Flamingo 2022.2.1 Patch 1后,我收到了任务“:app:kaptDebugKotlin”的错误执行失败

nwo49xxi  于 2023-05-15  发布在  Android
关注(0)|答案(1)|浏览(185)

我得到了“任务':app:kaptDebugKotlin'执行失败”的错误
任务':app:kaptDebugKotlin'执行失败。 执行org.jetbrains.Kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction java.lang.reflect.InvocationTargetException时出错(无错误消息)
我的Mac是英特尔的,所以M1不是问题。我尝试了很多关于堆栈溢出的建议。但我还是找不到答案,,,
我的gradle JDK是17.0.6
app build.gradle

android {
compileOptions {
        targetCompatibility JavaVersion.VERSION_11
        sourceCompatibility JavaVersion.VERSION_11
    }

    kotlinOptions {
        jvmTarget = '11'
    }
}

dependencies {
    api fileTree(include: ['*.jar', '*.aar'], dir: 'libs')

    implementation "com.google.android.gms:play-services-tasks:18.0.1"
    // Ted permission
    implementation "gun0912.ted:tedpermission:$rootProject.tedPermissionVersion"

    // fragmentF
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
    //noinspection GradleDependency
    implementation 'androidx.browser:browser:1.3.0'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.viewpager2:viewpager2:1.0.0'
    testImplementation 'junit:junit:4.13.2'

    // android support libraries
    implementation 'androidx.appcompat:appcompat:1.4.0'
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'com.google.android.material:material:1.4.0'
    implementation "org.jetbrains.kotlin:kotlin-stdlib:1.6.10"

    // dependency injection
    implementation "com.google.dagger:dagger:2.35.1"
    kapt "com.google.dagger:dagger-compiler:$rootProject.ext.dagger2Version"
    kapt "com.google.dagger:dagger-android-processor:$rootProject.ext.dagger2Version"
    implementation "com.google.dagger:dagger-android-support:$rootProject.ext.dagger2Version"

    // reactive
    implementation "io.reactivex.rxjava2:rxjava:2.2.15"
    implementation "io.reactivex.rxjava2:rxandroid:2.1.1"

    // view model
    implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
    implementation "androidx.lifecycle:lifecycle-common-java8:2.4.0"

    //room DB
    def room_version = "2.3.0"
    implementation "androidx.room:room-runtime:$room_version"
    kapt "androidx.room:room-compiler:$room_version"

    implementation 'com.google.android.gms:play-services-location:19.0.1'

    //sliding up panel
    implementation 'com.sothree.slidinguppanel:library:3.4.0'

    •••
}

包build.gradle

buildscript {
    ext.kotlin_version = '1.6.10'

    repositories {
        jcenter()
        google()
        mavenCentral()
        maven { url 'https://maven.google.com' }
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.android.tools.build:gradle:7.1.1'
        classpath 'com.google.gms:google-services:4.3.10'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.0'
        // NOTE: Do not Store your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

ext {
    // Sdk and tools
    minSdkVersion = 24
    targetSdkVersion = 31
    compileSdkVersion = 31
    buildToolsVersion = '30.0.2'

    // App dependencies
    supportLibraryVersion = '28.0.0'
    retrofit2Version = '2.9.0'
    okhttp3Version = '4.9.0'
    rx2FastAndroidNetworking = '1.0.2'
    dagger2Version = '2.16'
    rxjava2Version = '2.1.9'
    rxandroidVersion = '2.0.2'
    lifecycle = '1.1.1'

    kakaoVersion = '2.10.0'

    tedPermissionVersion = "2.2.3"

    // Test dependencies
    junitVersion = '4.12'
    espressoVersion = '3.0.1'
    mockitoVersion = '2.15.0'
    excludeAppGlideModule = true
}

gradle.properties

org.gradle.jvmargs=-Xmx3072m -XX:+UseParallelGC
android.useAndroidX=true
android.enableJetifier=true
android.databinding.incremental=true
android.debug.obsoleteApi=true
#android.enableR8 = true
-Pandroid.incrementalJavaCompile=false
org.gradle.unsafe.configuration-cache=warn
rekjcdws

rekjcdws1#

我的问题是Android Studio JDK版本和我的Java版本不同···
升级Android Studio后,其JDK版本设置为JDK 17。Java版本是14.0.1。所以,我把两者放在同一个版本中。
这就是为什么我坚持在构建错误,,!所以,,愚蠢的,
不管怎样,我希望有人能轻松解决这种问题!

check in terminal : java -version

check the JDK version in Android Studio : settings > Build > Gradle > 'Gradle JDK'

相关问题