flutter开发 android工程报错Failed to apply plugin class ‘FlutterPlugin‘

慈云数据 12个月前 (04-11) 技术支持 41 0

Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin class 'FlutterPlugin'.

flutter开发 android工程报错Failed to apply plugin class ‘FlutterPlugin‘
(图片来源网络,侵删)
pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
}
dependencyResolutionManagement {
        //    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 会报错Failed to apply plugin class ‘FlutterPlugin
        //    repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)//会报错 io.flutter.embedding找不到
    repositoriesMode.set(RepositoriesMode.PREFER_PROJECT)//修改这一行代码
    repositories {
        google()
        mavenCentral()
    }
}
rootProject.name = "BoostTestAndroid"
include ':app'
setBinding(new Binding([gradle: this]))
evaluate(new File(
        settingsDir.parentFile,
        'flutter_module/.android/include_flutter.groovy'
))
include ':flutter_module'
project(':flutter_module').projectDir = new File('../flutter_module')

RepositoriesMode配置构建中仓库如何设置,总共有三种方式:

FAIL_ON_PROJECT_REPOS

flutter开发 android工程报错Failed to apply plugin class ‘FlutterPlugin‘
(图片来源网络,侵删)

表示如果工程单独设置了仓库,或工程的插件设置了仓库,构建就直接报错抛出异常

PREFER_PROJECT

表示如果工程单独设置了仓库,就优先使用工程配置的,忽略settings里面的

PREFER_SETTINGS

表述任何通过工程单独设置或插件设置的仓库,都会被忽略

settings.gradle里配置了FAIL_ON_PROJECT_REPOS,而Flutter插件又单独设置了repository,所以会构建报错,因此需要把FAIL_ON_PROJECT_REPOS改成PREFER_PROJECT。

最后sync now一下

微信扫一扫加客服

微信扫一扫加客服