Android Studio - Failed to notify project evaluati

2019-02-01 16:15发布

Following is the build.gradle code in Android Studio

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.sg.blahblah"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }

    lintOptions {
        checkReleaseBuilds true
        abortOnError false
        xmlReport true
        htmlReport true
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

            lintOptions {
                disable 'MissingTranslation'
            }
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.android.support:support-v4:23.1.1'
    compile 'com.android.support:cardview-v7:23.1.1'
    compile 'com.google.android.apps.dashclock:dashclock-api:+'
    compile 'com.roughike:bottom-bar:1.4.0.1'
    compile 'com.diogobernardino:williamchart:2.2'
}

I am getting the below error: Error:A problem occurred configuring project ':app'.

Failed to notify project evaluation listener. com.android.build.gradle.tasks.factory.AndroidJavaCompile.setDependencyCacheDir(Ljava/io/File;)V

Can anyone please help?

Following is the Instant Run screenshot enter image description here

25条回答
时光不老,我们不散
2楼-- · 2019-02-01 16:28

The problem is probably you're using a Gradle version rather than 3. go to gradle/wrapper/gradle-wrapper.properties and change the last line to this:

distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
查看更多
Melony?
3楼-- · 2019-02-01 16:29

It is interesting but as for me help this:

 File -> Setting -> Gradle -> disable offline work
查看更多
SAY GOODBYE
4楼-- · 2019-02-01 16:30

I also encountered this error when updating to 'com.android.tools.build:gradle:3.0.0'

To fix it, I had to add the google() repo to both the buildscript and module repositories. The documentation here only mentions adding to to the buildscript.

Project-level build.gradle

buildscript {
    repositories {
        ...
        // You need to add the following repository to download the
        // new plugin.
        google()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
    }
}

App-level build.gradle

repositories {
    ...
    // Documentation doesn't specify this, but it must be added here
    google()
}

gradle-wrapper.properties

...
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
查看更多
小情绪 Triste *
5楼-- · 2019-02-01 16:30

Usually it depends on Instant run or Gradle, but I tried both variants and nothing helped me. Then I looked through idea.log and saw this error

Caused by: java.lang.RuntimeException: A conflict was found between the 
following modules:
 - com.android.support:support-core-utils:25.3.1
 - com.android.support:support-core-utils:27.0.1

I really don't know why this error is not shown in Gradle Console or Event Log tab. Then I fixed it by adding some code to the end of android{} block.

configurations.all {
    resolutionStrategy {
        failOnVersionConflict()
        eachDependency { DependencyResolveDetails details ->
            if (details.requested.name == 'support-core-utils') {
                details.useVersion '25.3.1'//Or you can use 27.0.1 if it does not conflict with your other dependencies
            }
    }
}
查看更多
趁早两清
6楼-- · 2019-02-01 16:30

I had buildToolsVersion "27.0.1", upgrading it to 27.0.2 fixed the issue.

Also, my android support deps were at version 27.0.2 so they were not aligned to the buildToolsVersion

查看更多
迷人小祖宗
7楼-- · 2019-02-01 16:31

For those of you working on a team:

I pulled down some changes that included updating the build tools version, but I had not downloaded that new version of the build tools on my machine. Downloading the new version fixed this issue for me

查看更多
登录 后发表回答