我想使用poi 的依赖,于是我直接添加依赖。
dependencies {
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'top.zibin:Luban:1.1.8'
implementation 'com.github.bumptech.glide:glide:4.12.0'
implementation 'com.github.andyxialm:ColorDialog:1.0.0'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(path: ':zloadingview')
implementation project(path: ':magicindicator')
implementation project(path: ':pictureselector')
implementation project(path: ':jellyrefresh')
implementation project(path: ':photo')
implementation project(path: ':loopview')
implementation 'io.github.bmob:android-sdk:3.8.4'
implementation "io.reactivex.rxjava2:rxjava:2.2.8"
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'com.squareup.okhttp3:okhttp:4.8.1'
implementation 'com.squareup.okio:okio:2.2.2'
implementation 'com.google.code.gson:gson:2.8.5'
implementation group: 'org.apache.poi', name: 'poi', version: '3.8'
implementation group: 'org.apache.poi', name: 'poi-ooxml', version: '3.8'
implementation group: 'org.apache.poi', name: 'poi-ooxml-schemas', version: '3.8'
}
编译没有问题,运行报错。这个报错是什么含义?
Execution failed for task ':wangge:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
首先,单独使用poi 和bmob的依赖是没有问题的,但是加上了项目的其他依赖就出问题了,报错提示也分析不出哪里有问题。
于是我想到第二种办法,把已经封装好poi的项目当成 library 引入到现有的项目。然后出现以下问题:
Android dependency 'androidx.appcompat:appcompat' has different version for the compile (1.0.2) and runtime (1.1.0) classpath. You should manually set the same version via DependencyResolution
显然是两个版本冲突了。
项目原来的版本是:
implementation 'androidx.appcompat:appcompat:1.0.2'
导入的版本是:
implementation 'androidx.appcompat:appcompat:1.1.0'
于是我把导入module的版本改成 1.0.2 但是报错。
Android dependency 'androidx.appcompat:appcompat' has different version for the compile (1.0.2) and runtime (1.1.0) classpath. You should manually set the same version via DependencyResolution
和之前的没改的报错一样?不理解,1.1.0 版本已经被我替换成了 1.0.2 。现在项目都是 1.0.2 哪里来个 1.1.0 ?
于是换个方式,项目版本改成和导入module一致 1.1.0版本。这个报错没有了,有了新的报错:
Execution failed for task ':wangge:processDebugManifest'.
> Manifest merger failed with multiple errors, see logs
这是什么情况?究竟是哪里的问题?
请给每个问题答疑,我的需求就是让已有的项目可以使用 poi 包解析excel。有什么解决办法吗
ava.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerExceptio
报错的解决方法:
增加一个
implementation 'com.android.support:support-v4:28.0.0'
就没有问题了
可以提供下,完整的代码吗,这样的话,不好解决问题
gradle项目当发生依赖冲突的时候统一指定使用一个版本或者调整到同一个版本即可。
给一个示例:
在Maven中声明排除依赖是这么做的:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
在Gradle中声明测试依赖需要这么做:
dependencies {
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
}