问题遇到的现象和发生背景
flutter利用fat-aar打包报时,app下bulid.gradle的 embed 第三方库时报错
问题相关代码,请勿粘贴截图
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.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
def isAarLibrary = true
if(isAarLibrary ) {
apply plugin: 'com.android.library'
} else {
apply plugin: 'com.android.application'
}
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
if(isAarLibrary)
{
apply plugin: 'com.kezong.fat-aar'
}
android {
compileSdkVersion 30
ndkVersion "22.1.7171670"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
if(!isAarLibrary )
applicationId "com.example.untitled1"
minSdkVersion 16
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
if(isAarLibrary )
{
ndk {
abiFilters "armeabi","armeabi-v7a","armeabi-v8a"
}
}
}
buildTypes {
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
/*libraryVariants.all { variant ->
appendVersionName(variant, defaultConfig)
}*/
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation fileTree(dir: 'libs', include: ['.jar','.aar'])
if (isAarLibrary) {
embed "io.flutter:flutter_embedding_release:1.0.0-d3ea636dc5d16b56819f3266241e1f708979c233"
embed "io.flutter:arm64_v8a_release:1.0.0-d3ea636dc5d16b56819f3266241e1f708979c233"
embed "io.flutter:armeabi_v7a_release:1.0.0-d3ea636dc5d16b56819f3266241e1f708979c233"
def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
if (pluginsFile.exists()) {
pluginsFile.withReader('UTF-8') {
reader -> plugins.load(reader)
println 'read'
}
println 'exist'
}
else
{
println 'donot exist'
}
plugins.each { name, _ ->
println 'start'
println ":$name"
//这里报错Project with path ':path_provider_linux' could not be found in project ':app'.
embed project(path: ":$name", configuration: 'default')
}
}
}