flutter webview_flutter插件由于gradle问题而无法工作?

时间:2019-02-08 13:20:55

标签: gradle webview dart flutter

在flutter项目中添加flutter webview插件时出现gradle错误

嗨,我正在开发带有Flutter的应用程序,并且在我添加之前,它一直有效 flutter webview插件,然后出现此错误:

* Error running Gradle:
ProcessException: Process "C:\Users\p.mikaeil\Desktop\Files\Flutter Project\newapp\android\gradlew.bat" exited abnormally:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not find com.android.tools.build:gradle:4.10.2.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.10.2/gradle-4.10.2.pom
       - https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.10.2/gradle-4.10.2.jar
       - https://jcenter.bintray.com/com/android/tools/build/gradle/4.10.2/gradle-4.10.2.pom
       - https://jcenter.bintray.com/com/android/tools/build/gradle/4.10.2/gradle-4.10.2.jar
     Required by:

我尝试更改android文件夹中的gradle版本,但没有解决问题。

我该如何解决此问题? 感谢任何建议。

1 个答案:

答案 0 :(得分:1)

大量搜索和测试后,我找到了问题的解决方案:;

问题是因为我的存储库无法正常工作。

在解决问题之前,我的Project Build.gradle是这样的:

buildscript {
    repositories {
        google()
        jcenter()

    }

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

allprojects {
    repositories {
        google()
        jcenter()

}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

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

解决问题之后,Project Build.gradle应该是这样的:

buildscript {
    repositories {
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        jcenter()
        maven {
            url 'https://mvnrepository.com/artifact/com.android.tools.lint/lint-gradle-api'
        }
    }

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

allprojects {
    repositories {
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        jcenter()
        maven {
            url 'https://mvnrepository.com/artifact/com.android.tools.lint/lint-gradle-api'
        }
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

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

我也将Android应用程序build.gradle中的Compile Sdk版本和Target Sdk版本更改为28。

并且您还应该检查插件版本与android x的兼容性。

感谢这个伟大的社区。