环境
Flutter :flutter_windows_2.5.3-stable
Operating System: [Windows]
Gradle Plugin Version: [4.1.0]
Gradle Version: [6.5]
Fat-aar Version: [1.3.8]
错误信息
D:\03_WorkSpace\my_flutter_module>flutter build aar
Building with sound null safety
Running Gradle task 'assembleAarDebug'... 3.9s
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\Public\flutter_windows_2.5.3-stable\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 881
* What went wrong:
A problem occurred configuring project ':app'.
> Could not get unknown property 'applicationVariants' for extension 'android' of type com.android.build.gradle.LibraryExtension.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 3s
Gradle task assembleAarDebug failed with exit code 1.
build.gradle 配置
flutter 以 module 形式创建,以下是app build.gradle 设置:
// D:\03_WorkSpace\my_flutter_module\.android\app\build.gradle
def flutterPluginVersion = 'managed'
apply plugin: 'com.android.library'
apply plugin: 'com.kezong.fat-aar'
android {
compileSdkVersion 30
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.0"
}
buildTypes {
profile {
initWith debug
}
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
buildDir = new File(rootProject.projectDir, "../build/host")
dependencies {
implementation project(':flutter')
implementation fileTree(dir: 'libs', include: ['*.jar'])
compileOnly 'androidx.appcompat:appcompat:1.0.2'
compileOnly 'androidx.constraintlayout:constraintlayout:1.1.3'
embed 'io.flutter:flutter_embedding_release:1.0.0-d3ea636dc5d16b56819f3266241e1f708979c233'
embed 'io.flutter:armeabi_v7a_release:1.0.0-d3ea636dc5d16b56819f3266241e1f708979c233'
embed 'io.flutter:arm64_v8a_release:1.0.0-d3ea636dc5d16b56819f3266241e1f708979c233'
embed 'io.flutter:x86_64_release:1.0.0-d3ea636dc5d16b56819f3266241e1f708979c233'
}
期望结果
请问这个错误如何解决啊?有什么解决思路可提供参考吗?