Flutter: Failed to notify project evalution listener

2018-10-25 13:26:48 浏览数 (1)

又是一个常见的flutter的环境问题,一般发生在引用了plugin之后。因为默认的gradle,kotlin之类的比较旧,而所引用的plugin里面的gradle,kotlin比较新。所以会有这个问题,如图:

457973DC7C5759AC9878F11442EBDBAB.png457973DC7C5759AC9878F11442EBDBAB.png

解决方式也是很简单,一顿升级gradle,gradle wrapper和kotlin。

仅以android studio为例:

首先,右键你的flutter项目,选择Flutter->Open Android Module in Android Studio。

image.pngimage.png

如上图,有几个build.gradle文件,依次打开找到如下代码(如果有的话):

代码语言:txt复制
buildscript {
    ext.kotlin_version = '1.2.30'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

ext.kotlin_version = '1.2.30'换成ext.kotlin_version = '1.2.71',把classpath 'com.android.tools.build:gradle:3.1.0'换成classpath 'com.android.tools.build:gradle:3.2.1'

再打开gradle-wrapper.properties,如下:

代码语言:txt复制
#Wed Oct 10 15:20:17 CST 2018
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

distributionUrl=https://services.gradle.org/distributions/gradle-4.4-all.zip换成distributionUrl=https://services.gradle.org/distributions/gradle-4.6-all.zip

至此问题解决。

有的朋友打包里还可能会遇到下面的问题:

代码语言:txt复制
Unable to resolve dependency for ':app@dynamicProfile/compileClasspath': Could not resolve project :fluwx.
Open File
Show Details


Unable to resolve dependency for ':app@dynamicProfile/compileClasspath': Could not resolve project :sona.
Open File
Show Details


Unable to resolve dependency for ':app@dynamicProfileUnitTest/compileClasspath': Could not resolve project :fluwx.
Open File
Show Details

distributionUrl=https://services.gradle.org/distributions/gradle-4.4-all.zip换成distributionUrl=https://services.gradle.org/distributions/gradle-4.10.1-all.zip就解决了。

希望本文对你有所帮助。欢迎加入 OpenFlutter交流群:892398530。

0 人点赞