Android Studio 无法同步 Gradle 个文件

AndroidStudio fails to sync Gradle files

最近,AndroidStudio 停止为我工作。

如果我同步到 gradle 个文件,我会收到此错误:

Gradle 同步失败:org/jetbrains/kotlin/kapt/idea/KaptGradleModelorg/jetbrains/kotlin/kapt/idea/KaptGradleModel

日志:

2019-03-05 14:32:47,370 [d thread 7]   WARN - ect.sync.idea.ProjectSetUpTask - java.lang.NoClassDefFoundError: org/jetbrains/kotlin/kapt/idea/KaptGradleModel
    at com.android.tools.idea.gradle.project.sync.idea.AndroidGradleProjectResolver.populateKaptKotlinGeneratedSourceDir(AndroidGradleProjectResolver.java:359)
    at com.android.tools.idea.gradle.project.sync.idea.AndroidGradleProjectResolver.populateModuleContentRoots(AndroidGradleProjectResolver.java:250)
    at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.populateModuleContentRoots(AbstractProjectResolverExtension.java:95)
    at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.populateModuleContentRoots(AbstractProjectResolverExtension.java:95)
    at org.jetbrains.plugins.gradle.service.project.TracedProjectResolverExtension.populateModuleContentRoots(TracedProjectResolverExtension.java:62)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.doResolveProjectInfo(GradleProjectResolver.java:383)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.access0(GradleProjectResolver.java:76)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:879)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:863)
    at org.jetbrains.plugins.gradle.service.execution.GradleExecutionHelper.execute(GradleExecutionHelper.java:209)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:141)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:76)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.lambda$resolveProjectInfo[=11=](RemoteExternalSystemProjectResolverImpl.java:37)
    at com.intellij.openapi.externalSystem.service.remote.AbstractRemoteExternalSystemService.execute(AbstractRemoteExternalSystemService.java:58)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.resolveProjectInfo(RemoteExternalSystemProjectResolverImpl.java:37)
    at com.intellij.openapi.externalSystem.service.remote.wrapper.ExternalSystemProjectResolverWrapper.resolveProjectInfo(ExternalSystemProjectResolverWrapper.java:45)
    at com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask.doExecute(ExternalSystemResolveProjectTask.java:100)
    at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:163)
    at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:149)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil.execute(ExternalSystemUtil.java:573)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil.run(ExternalSystemUtil.java:678)
    at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:736)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess(CoreProgressManager.java:157)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:580)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:525)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:85)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:144)
    at com.intellij.openapi.progress.impl.CoreProgressManager.run(CoreProgressManager.java:395)
    at com.intellij.openapi.application.impl.ApplicationImpl.run(ApplicationImpl.java:314)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

2019-03-05 14:32:47,370 [d thread 7]   WARN - ect.sync.idea.ProjectSetUpTask - org/jetbrains/kotlin/kapt/idea/KaptGradleModelorg/jetbrains/kotlin/kapt/idea/KaptGradleModel 
2019-03-05 14:32:47,370 [d thread 7]   INFO - e.project.sync.GradleSyncState - Gradle sync failed: org/jetbrains/kotlin/kapt/idea/KaptGradleModelorg/jetbrains/kotlin/kapt/idea/KaptGradleModel

谷歌搜索这个错误时,人们提到要重新安装 Kotlin 插件。

但问题是:我从未安装过 Kotlin 插件。我不使用 Kotlin,我只使用 NDK 和 Java.

这一直工作得很好。

AndroidStudio 最近是否添加了对 Kotlin 插件的要求?我现在必须安装 Kotlin 吗?

更新

$ rm -rf ~/.gradle 解决方案没有帮助。

菜单选项无效缓存/重新启动没有帮助。

相关问题(升级到 Gradle 5.2.1)提供的 没有帮助。

OS: Ubuntu LTS

AndroidStudio version:3.3.2

顶级gradle文件:

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.2'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

应用程序的 gradle 文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    lintOptions {
        checkReleaseBuilds false
    }
    defaultConfig {
        applicationId "com.steenriver.armor"
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 134
        versionName "1.34"
        ndk {
            abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86'
        }
        externalNativeBuild {
            cmake {
                cFlags "-DCP_USE_DOUBLES=0 -DCP_USE_CGTYPES=0"
                cppFlags "-std=c++11 -DANDROID=1 -DPLAY=1 -DUSEES3=1 -DLOGTAG=armor -DCP_USE_DOUBLES=0 -DCP_USE_CGTYPES=0 -DAPPVER=$versionName"
                arguments "-DCMAKE_VERBOSE_MAKEFILE=0", "-DANDROID_TOOLCHAIN=clang", "-DANDROID_ARM_NEON=TRUE", "-DANDROID_ARM_MODE=arm"
            }
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            useProguard false
        }
        debug {
            externalNativeBuild {
                cmake {
                    cppFlags += "-DDEBUG"
                }
            }
        }
    }
    externalNativeBuild {
        cmake {
            path '../../Android/jni/CMakeLists.txt'
        }
    }
}


dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    testImplementation 'junit:junit:4.12'
    api 'com.android.support:support-v4:28.0.0'
    api 'com.android.support:appcompat-v7:28.0.0'

    api 'com.google.android.gms:play-services-auth:16.0.1'
    api 'com.google.android.gms:play-services-nearby:16.0.0'
    api 'com.google.android.gms:play-services-games:16.0.0'
    api 'com.android.billingclient:billing:1.1'
}

我尝试了很多方法,但我能够消除此错误的唯一方法是 启用 Kotlin 插件

这个我觉得很奇怪,因为:

  • 以前没有 Kotlin 插件也能正常工作。
  • 我在任何地方都不使用任何 Kotlin 代码。只是 Java、C 和 C++。

我怀疑 Android Studio 最近在某个地方发现了对 Kotlin 的错误依赖。这很不幸。我不明白为什么需要这个插件。