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:45

This is neither an exact answer to the question nor a silver bullet. However, if nothing works for you e.g. Invalidate cache & restart, Checking build dependency, Disabling Instant Run (I never advise that) etc.

  1. Add command-line option --stacktrace in Setting > Build, Execution, Deployment > Compiler
  2. Now build/assemble gradle once again. You will have detailed information about the cause. e.g. in my case:

Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find com.squareup.okhttp3:logging-interceptor:3.9.1Net.

I have misspelled the dependency name in module level gradle file. Hope that help

查看更多
地球回转人心会变
3楼-- · 2019-02-01 16:45

For me, this issue arose due to an incompatible combination of plugin and gradle.

I added these to the code to have it working:

Main build.gradle

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

Main gradle-wrapper.properties:

distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
查看更多
老娘就宠你
4楼-- · 2019-02-01 16:46

First Step:File → Settings → Build, Execution, Deployment → Instant Run and uncheck Enable Instant Run. Second step: Press Invalidate/Restart. done.... Enjoy.

查看更多
混吃等死
5楼-- · 2019-02-01 16:46

In my case, I had to do -

File -> Sync Project with Gradle Files

Sync Project with Gradle Files

查看更多
啃猪蹄的小仙女
6楼-- · 2019-02-01 16:48

In my case, I was missing the target SDK platform installed. I remember this error was straightforward and prompted you to install it automatically. Worth checking that as well.

查看更多
一夜七次
7楼-- · 2019-02-01 16:49

had similar problem, issue was different versions of included library. to find out what causes problem run build command with stacktrace

./gradlew build --stacktrace
查看更多
登录 后发表回答