Ich habe mehrere Android-Bibliotheken und Module in meinem Projekt verwendet. Jeder hat seine eigene v4.Support-Lib. Ich erhalte java.util.zip.ZipException: doppelten Eintrag. Wenn ich im Projekt nach der doppelten Klassendatei suche, gibt es mehrere Dateien dieser Klassen, weil mehrere v4.support-Bibliotheken in jeder Bibliothek vorhanden sind. Ich weiß, dass diese Frage schon oft gestellt wurde, aber nichts funktioniert für mich.java.util.zip.ZipException: Doppeleintrag: Wie zu überwinden
Meine Frage ist: Wie diese mehrere v4.support Dateien zu entfernen? Ich möchte diese v4.support-Lib nur einmal und alle anderen Module sollten es von dort verweisen. Wie erreiche ich das?
Es folgt mein build.gradle Skript
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
//classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
classpath 'io.fabric.tools:gradle:1.15.2'
}
}
apply plugin: 'android'
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile('com.crashlytics.sdk.android:crashlytics:[email protected]') {
transitive = true
}
compile('com.android.support:multidex:1.0.0')
//compile ('com.android.support:appcompat-v7:22.1.0')
compile project(':..:..:..:..:..:..:android_libraries:appcompat')
compile project(':..:..:..:..:..:..:android_libraries:facebook')
compile project(':..:..:..:..:..:..:android_libraries:google_play_services:libproject:google-play-services_lib')
compile project(':..:..:..:..:..:..:android_libraries:SlidingMenu')
compile project(':..:..:..:..:..:..:android_libraries:StickingGridViewLibrary')
compile project(':..:..:..:..:..:..:android_libraries:view_pager_library')
compile project(':..:..:..:..:..:..:android_libraries:ZXing2.3')
compile project(':..:..:..:..:..:..:android_libraries:xyz')
compile project(':..:..:..:..:..:..:android_libraries:apptentive')
}
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
versionCode 1
versionName "1.0"
minSdkVersion 15
targetSdkVersion 21
// Enabling multidex support.
multiDexEnabled true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
ant.importBuild './../../../../../../buildscripts/wlbuild.xml'
apt {
arguments {
androidManifestFile variant.outputs[0].processResources.manifestFile
// if you have multiple outputs (when using splits), you may want to have other index than 0
resourcePackageName 'com.kohls.mcommerce.opal'
// If you're using Android NBS flavors you should use the following line instead of hard-coded packageName
// resourcePackageName android.defaultConfig.applicationId
// You can set optional annotation processing options here, like these commented options:
// logLevel 'INFO'
// logFile '/var/log/aa.log'
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
buildDir = './../../../../../../build/native'
lintOptions {
abortOnError false
}
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
}
Und ich Fehler wie diese zu bekommen. Jedes Mal, wenn ich das Projekt säubere, erfüllt es sich erfolgreich. Aber wenn ich versuche, Run-Befehl zu geben, zeigt es die folgenden Arten von Fehler an.
Execution failed for task ':packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: android/support/v4/media/TransportMediatorCallback.class
In meinem Fall. Für Android Studio habe ich Strg + N gedrückt und nach dem Klassennamen gesucht, der in diesem Fall TransportMediatorCallback ist, der aus "Doppeleintrag: Android/support/v4/media/TransportMediatorCallback" stammt.Klasse " Sie war in mehreren JAR-Dateien vorhanden (3, um genau zu sein). Ich entfernte 2 und zum Auflösen der Abhängigkeiten in anderen Bibliothekspaketen, zeigte einfach auf diese Bibliotheken mit ../source_library_package/libs/library_name.jar –
@ RohitRokde, Correct.Auf diese Weise können wir herausfinden, welche Bibliotheken dupliziert sind in unserer App. –
Was ist, wenn die Abhängigkeiten nicht in den Modulen in der Projektstruktur aufgelistet sind? Dies kann wegen transitiver Abhängigkeiten in anderen JARs passieren. –