Android Studio更新setDependencyCacheDir错误

时间:2018-09-13 04:35:49

标签: android android-studio android-gradle

如何解决此错误:

Android Studio:3.1.4 摇篮版本:4.4 Android插件版本:3.1.4

What went wrong:
A problem occurred configuring root project 'myApplication'.
> Failed to notify project evaluation listener.
   > com.android.build.gradle.tasks.factory.AndroidJavaCompile.setDependencyCacheDir(Ljava/io/File;)

我当前的项目正在使用旧Gradle(4.4)和Android Plugin版本(2.14.1)以及新的Android Studio(3.1.4)吗?

2 个答案:

答案 0 :(得分:1)

尝试删除根目录和项目存储库中的构建文件夹,也尝试删除gradle缓存文件夹可能会有所帮助。通常是因为根文件夹中有一些损坏的文件

答案 1 :(得分:0)

更新gradle-wrapper.properties文件

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

和根项目依赖项

 dependencies {
        //Gradle dependencies 
        classpath 'com.android.tools.build:gradle:3.1.4'

        // Kotlin if use kotlin your project
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.0"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }