我有一个Android(Java)项目,并且迁移到AndroidX之后,我收到以下错误(d8 errors)
:
Program type already present: com.enterprisedt.BaseIOException
请注意,gradle同步正常发生。该错误仅在设备编译时出现。最奇怪的是,它只会在我为Android 4设备进行编译时发生。 尝试针对Android 5+进行编译时,编译成功且应用程序运行平稳。
build.gradle
[...]
compileSdkVersion 28
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0.0"
applicationId "br.com.example"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
ndk.abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64'
}
dependencies {
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
all*.exclude group: 'com.android.support', module: 'support-annotations'
all*.exclude group: 'com.android.support', module: 'appcompat-v7'
all*.exclude group: 'com.android.support', module: 'support-v13'
}
implementation project(':mylib')
// These 3 libraries are required for the project.
implementation files("libs/activation.jar")
implementation files("libs/mail.jar")
implementation files("libs/edtftpj.jar")
implementation files("libs/commons-net-3.0.1.jar")
implementation files("libs/commons-validator-1.4.0.jar")
implementation files("libs/itextpdf-5.4.0.jar")
implementation('com.appsee:appsee-android:2.3.3@aar') {
transitive = true
}
implementation('com.optimizely:optimizely:1.4.2@aar') {
transitive = true
}
implementation('io.fabric.sdk.android:fabric:1.4.8@aar') {
transitive = true
}
implementation('com.crashlytics.sdk.android:crashlytics:2.10.1@aar') {
transitive = true
}
implementation "com.onesignal:OneSignal:$oneSignalVersion"
implementation "androidx.percentlayout:percentlayout:$percentLayoutVersion"
implementation "androidx.legacy:legacy-support-v4:$legacyVersion"
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
implementation "androidx.recyclerview:recyclerview:$recyclerViewVersion"
implementation "androidx.annotation:annotation:$androidxAppCompatVersion"
implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion"
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.google.guava:guava-collections:r03'
implementation 'com.google.firebase:firebase-core:17.2.0'
implementation "com.google.android.material:material:$materialVersion"
implementation "com.google.android.gms:play-services-maps:$gmsVersion"
implementation "com.google.android.gms:play-services-analytics:$gmsVersion"
implementation 'com.google.dagger:dagger:2.24'
annotationProcessor 'com.google.dagger:dagger-compiler:2.24'
implementation 'com.squareup:otto:1.3.8'
implementation 'org.jetbrains:annotations:17.0.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'com.squareup.picasso:picasso:2.71828', {
exclude group: 'com.android.support', module: 'support-annotations'
}
implementation 'com.lapism:searchview:4.0'
implementation 'com.sromku:simple-storage:1.2.0'
implementation 'me.dm7.barcodescanner:zxing:1.9.8', {
exclude group: 'com.android.support', module: 'appcompat-v7'
}
implementation 'com.nononsenseapps:filepicker:2.5.2'
implementation 'io.github.yavski:fab-speed-dial:1.0.6'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.1'
implementation 'com.github.arimorty:floatingsearchview:2.1.1'
implementation 'net.i2p.android.ext:floatingactionbutton:1.10.1'
implementation 'org.zakariya.stickyheaders:stickyheaders:0.7.11'
implementation 'com.weiwangcn.betterspinner:library-material:1.1.0'
implementation 'com.prolificinteractive:material-calendarview:1.4.3'
implementation 'uk.co.chrisjenx:calligraphy:2.3.0', {
exclude group: 'com.android.support', module: 'appcompat-v7'
}
// debug
debugImplementation 'com.facebook.stetho:stetho:1.5.1'
debugImplementation 'com.gu.android:toolargetool:0.1.5@aar'
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-all:1.10.19'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha02', {
exclude group: 'com.android.support', module: 'support-annotations'
}
}
[...]
build.gradle(项目)
buildscript {
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://maven.google.com' }
maven { url 'https://plugins.gradle.org/m2/'}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.5'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
classpath 'io.fabric.tools:gradle:1.31.1'
classpath 'com.google.gms:google-services:4.3.2'
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://www.jitpack.io" }
maven { url 'http://dl.bintray.com/optimizely/optimizely' }
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://maven.google.com' }
maven { url "https://oss.sonatype.org/content/repositories/snapshots"}
maven { url 'https://dl.bintray.com/guardian/android' }
}
}
build.gradle(本地库:“ mylib”)
[...]
compileSdkVersion 28
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
}
[...]
dependencies {
// here, I repeat those 3 libraries mentioned (activation, mail, edtftpj)
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.browser:browser:1.0.0'
implementation "com.google.android.gms:play-services-location:17.0.0"
implementation "com.google.android.gms:play-services-maps:17.0.0"
implementation "com.google.android.gms:play-services-analytics:17.0.0"
implementation "com.google.android.material:material:1.0.0"
implementation "androidx.appcompat:appcompat:1.1.0"
implementation "androidx.annotation:annotation:1.1.0"
implementation "androidx.cardview:cardview:1.0.0"
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
api 'br.com.concretesolutions:canarinho:1.1.0'
api 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
}
gradle.properties
org.gradle.jvmargs=-Xmx2048M
org.gradle.configureondemand=false
android.enableJetifier=true
android.useAndroidX=true
我提到的3个库(激活,邮件,edtftpj)必须同时存在于lib和project中,因为它们实际上已被使用。
我已经尝试过:
packagingOptions {
exclude 'com/sun/mail/dsn/mailcap'
exclude 'dsn.mf'
exclude 'javamail.charset.map'
exclude 'javamail.default.address.map'
exclude 'javamail.default.providers'
exclude 'javamail.imap.provider'
exclude 'javamail.pop3.provider'
exclude 'javamail.smtp.address.map'
exclude 'javamail.smtp.provider'
exclude 'mailcap'
exclude 'mimetypes.default'
exclude 'mailcap.default'
exclude 'com.enterprisedt.BaseIOException'
exclude 'javax.activation.*'
}
有人可以帮助我吗?