开发合并module遇到的问题

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.

> com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

遇到这个问题有三种可能性:

1,方法数超过

// dex突破65535的限制
multiDexEnabled true

这个时候如果你的 minSdkVersion 低于21

那么还需要加上

BaseApplication extends MultiDexApplication

以及依赖

compile 'com.android.support:multidex:1.0.1'

如果你得 minSdkVersion 大于等于21

则至于要加上

multiDexEnabled true

2.依赖的module和app的有重复的jar文件,这就需要你仔细查看,一般是v7 或者v4重复,如果发现重复包用

compile引用 不要用 implementation引用

implementation

这个指令的特点就是,对于使用了该命令编译的依赖,对该项目有依赖的项目将无法访问到使用该命令编译的依赖中的任何程序,也就是将该依赖隐藏在内部,而不对外部公开。

3,这种可能性就是

//implementation fileTree(include: ['*.jar'], dir: 'libs')
provided fileTree(dir: 'libs', include: ['*.jar'])
不要用
compile或者implementation引用  用
provided引用jar文件

现在的主要工具是apt maven gradle 。AndroidStudio 3.0以后 apt做了限制。工具使用不方便,所以使用gradle和maven就好了,gradle虽然有很多优点,方便,快捷。本地。但是maven我更看好。因为现在越来越多的SDK选择maven集成。不会出现莫名其妙的错误。只是编译的时候费点时间,


猜你喜欢

转载自blog.csdn.net/whs867712232/article/details/79744639