解决问题: Flutter plugin引用的.aar中包含的.so动态库, 未包含在app的debug build中.

问题: Flutter plugin ls_camera_plugin引用了camera.aar文件, 在.aar文件中包含的各架构的.so动态库. 在最终的app中, 通过pubspec.yaml引入了ls_camera_plugin, 发现通过flutter build apk生成的.apk是包含.aar中的动态库的, 但通过AndroidStudio的debug/run按钮, 或assembleDebug生成的.apk, 是不包含.so动态库文件的. 

解决方法:

1. 打开app和ls_camera_plugin的安卓工程.

2. 确保在ls_camera_plugin的根路径中包含的libs/camera.aar文件.

3. 在ls_camera_plugin的build.gradle中修改:


rootProject.allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url 'http://download.flutter.io'
        }
        flatDir {  // 关键部分
            dirs 'libs'
            dirs project(':ls_camera_plugin').file('libs')
        }
    }
}
......................
dependencies {
    implementation(name:'lscameralib', ext:'aar')  // 关键部分

    implementation 'androidx.annotation:annotation:1.1.0'

    // api "io.flutter:flutter_embedding_debug:1.0.0-d1bc06f032f9d6c148ea6b96b48261d6f545004f"
}

4. 在app/build.gradle中修改:

android{
    ....
    dependencies {
        implementation project(':ls_camera_plugin')
    }
}

5. 在app/settings.gradle中修改:

include ':app', ':ls_camera_plugin'

6. 如果遇到 "Program type already present" 的错误, 需要clean project再重新build. 如仍失败, 检查是否有重复的依赖

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值