2020.3.1版android studio 无法添加依赖库的解决方法(Failed to resolve: :flutter_debug-1.0.0:)
先说解决方法
1、把aar添加到libs目录下
2、implementation fileTree(dir: ‘libs’, include: [’.jar’,])修改为 implementation fileTree(dir: ‘libs’, include: [’.jar’,’*.aar’])
3、在setting.gadle文件里添加你的aar名称,同步后就可以正常使用了
如:include ‘flutter-debug’
解决过程
我更新到最新的版本后(2020.3.1版),新建一个空白项目,按照之前的操作,先把aar或者其他库添加到libs目录下,然后在app目录下的build.gradle里的dependencies添加配置:
-
implementation fileTree(dir: ‘libs’, include: [’*.jar’]);
-
implementation(name: ‘flutter_debug’, ext: ‘aar’);
同步后就报错,如图:
-
查询后发现需要把implementation fileTree(dir: ‘libs’, include: [’.jar’,])修改为 implementation fileTree(dir: ‘libs’, include: [’.jar’,’*.aar’])
-
再次同步后,在libraries里可以加载出添加的flutter了,但是还是报错:Failed to resolve: :flutter_debug:
-
然后查了好多,都是在settings.gradle的repositories 配置,但没什么效果,后来在融云(https://support.rongcloud.cn/ks/MTEyMA==)找到解决方法:
只需要添加include 'flutter-debug’就可以,不需要在repositories里做任何操作
另外,下面的对libs的配置已经不适用,改为了在dependencies里添加implementation fileTree(dir: ‘libs’, include: [’*.jar’])
repositories {
flatDir {
dirs 'libs' // aar目录
}
}
以上完结
不能创建flutter module 解决方法
之前可以通过 file --> new --> new module -->新建flutter module,但是现在没有了这个选项;而是通过file --> new --> new flutter project --> flutter 在新建flutter时,再修改为 module 来创建,如图:
创建flutter module 后,通过命令行生成aar或者apk
在终端cd 到项目的地址,然后输入
- 打包aar : flutter build aar --no-debug --no-profile
- 打包apk:flutter build apk --debug
注:要小写,否则报错;需要打包release版,把debug改为release就好