1

如何在flutter插件中使用本地aar库

 2 years ago
source link: https://www.myfreax.com/how-to-use-local-aar-inside-flutter-plugin/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
更新于 2021/08/8 |  创建于 2021/08/8

如何在flutter插件中使用本地aar库

当你使用Golang语言编写一个android安卓的库,并且编译为android的arr格式库时,你需要配置你gradle,让gradle寻找你所使用库的路径。

本文说明如何在flutter插件中使用本地aar库文件。

使用下面的flutter命令创建一个flutter插件

flutter create --org 你的包名 --template=plugin --platforms=android,ios -a kotlin 插件名称

然后创建一个libs 在插件的android 目录下,将生成的arr库存放在libs 下,如下图

I updated the build.gradle file for the android code to include the following:

然后更新flutter插件的android项目build.gradle文件,添加flatDir到repositories对象

rootProject.allprojects {
    repositories {
        google()
        jcenter()
        flatDir {
            dirs 'libs'
        }
    }
}

并且将arr库添加到依赖

implementation fileTree(dir: 'libs', include: ['*.aar'])



About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK