发现问题:
Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin class ‘FlutterPlugin’.
Caused by: org.gradle.api.internal.tasks.DefaultTaskContainer$DuplicateTaskException: Cannot add task ‘generateLockfiles’ as a task with that name already exists.
出现问题的原因:
flutter开发集成第三方sdk,创建module后,配置build.gradle引入flutter的sdk的方式后,Sync
目前我解决的办法是:之前的引入方式注释掉,在dependencies 中按照Android的方式引入
//plugins {
// id 'com.android.library'
//}
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
//将之前的引入方式注释
//apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
//flutter {source '../..'}
apply plugin: 'com.android.library'
android {
......
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation files('libs\\bdasr_V3_20210628_cfe8c44.jar')
//以这样的方式引入
compileOnly files("$flutterRoot//bin/cache/artifacts/engine/android-arm/flutter.jar")
}