flutter中如何引入android module依赖包

如何在flutter运用中引入自己定义的依赖包

本人在自己定义了一个Android library依赖包
如图:
在这里插入图片描述

方式有两中:

方式一
  1. 打开主程序[以后默认名字为app]的build.gradle.中添加:
dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
+   implementation project(':asr_plugin')//自己定义的依赖文件名
}
  1. 打开需要添加的插件asr_plugin的build.gradle文件
    修改 compileSdkVersion,targetSdkVersion 和app中build.gradle中保持一致
compileSdkVersion 28
targetSdkVersion 28

以及

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar']
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
如果你的 Flutter 项目使用了 Android V1 Embedding,但是你又需要打 APK,可以考虑升级为 Android V2 Embedding。具体步骤如下: 1. 在 `android/gradle.properties` 文件添加以下代码: ``` android.enableR8=false android.useAndroidX=true android.enableJetifier=true ``` 2. 在 `android/app/build.gradle` 文件,将 `compileSdkVersion` 和 `targetSdkVersion` 修改为 `29`。 3. 在 `android/app/build.gradle` 文件,将 `minSdkVersion` 修改为 `21`。 4. 在 `android/gradle/wrapper/gradle-wrapper.properties` 文件,将 `distributionUrl` 修改为以下内容: ``` distributionUrl=https://services.gradle.org/distributions/gradle-6.7-all.zip ``` 5. 在 `android/build.gradle` 文件,将 `classpath 'com.android.tools.build:gradle:3.4.0'` 修改为 `classpath 'com.android.tools.build:gradle:4.1.0'`。 6. 在 `android/gradle/wrapper/gradle-wrapper.properties` 文件,将 `distributionUrl` 修改为以下内容: ``` distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip ``` 7. 在 `android/app/build.gradle` 文件,将 `compileOptions` 修改为以下内容: ``` compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } ``` 8. 在 `android/app/build.gradle` 文件,将 `dependencies` 修改为以下内容: ``` dependencies { implementation 'com.android.support:multidex:1.0.3' implementation 'androidx.multidex:multidex:2.0.1' } ``` 完成以上步骤后,重新运行 Flutter 项目并打 APK 即可。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值