u010746454 2021-11-26 10:48 采纳率: 0%
浏览 9
已结题

flutter利用fat-aar打包报时,第三方包嵌入时报错

问题遇到的现象和发生背景

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')
        }
    }
}
运行结果及报错内容
我的解答思路和尝试过的方法
我想要达到的结果
  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 12月4日
    • 创建了问题 11月26日

    悬赏问题

    • ¥60 iinfercnv 肿瘤进化树
    • ¥15 如何入门学习c语言,单片机
    • ¥15 idea 编辑语言的选择
    • ¥15 Windows下部署Asmjit
    • ¥15 请问双层规划模型的上下层目标函数不一致,是如何保证迭代收敛性的
    • ¥15 微信小程序 前端页面内容搜索
    • ¥15 cpu是如何判断当前指令已经执行完毕,然后去执行下条指令的
    • ¥15 安装visual studio2022时visualstudiosetup启动不了,闪退。问题代号0x0和0x1389
    • ¥30 java spring boot2.5.3版本websocket连不上
    • ¥15 angular js调外部链接查看pdf