我一直在Android Studio中与这个错误作斗争。项目是从eclipse解决方案导入的。我一直在尝试实现针对类似帖子列出的所有修复,没有任何工作。我是Android初学者。
我很乐意提供更多信息。
错误:任务':app:packageAllDebugClassesForMultiDex'执行失败。
java.util.zip.ZipException:重复条目:com / google / zxing / BarcodeFormat.class
请帮忙!!我应该尝试让它在Eclipse中运行吗?
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.2'
}
}
allprojects {
repositories {
jcenter()
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.appname.android"
minSdkVersion 8
targetSdkVersion 18
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:22.1.1'
compile files('libs/ksoap2-android-assembly-3.1.0-jar-with-dependencies.jar')
provided files('libs/zxing-core.jar')
}
答案 0 :(得分:7)
确保您拥有SDK管理器中的最新版本toolds和sdk。我已将这些jars
转换为Gradle
个依赖项。
build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases/' } // <-- added for ksoap
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.3' // <-- updated
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases/' } // <-- added for ksoap
}
}
app/build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1" // <-- updated
defaultConfig {
applicationId "com.appname.android"
minSdkVersion 8
targetSdkVersion 22 // <-- updated
// multiDexEnabled true // <-- you do not need this
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:22.1.1'
compile 'com.google.code.ksoap2-android:ksoap2-android:3.4.0'
// compile files('libs/ksoap2-android-assembly-3.1.0-jar-with-dependencies.jar') // <-- avoid using jars
compile 'com.google.zxing:core:3.2.0'
// provided files('libs/zxing-core.jar') // <-- avoid using jars
}
答案 1 :(得分:2)
java.util.zip.ZipException:重复条目
我也面临同样的问题。但我得到了解决。
当我们将项目一个系统移动到另一个系统时,会出现此问题。因此,一个系统gradle版本和SDK工具版本与其他系统不同。
请检查您是从其他系统导入项目还是从互联网下载
1.您的系统和下载的应用程序的gradle版本是否匹配?
如果项目在同一系统中,但是你得到了相同的异常,那么上述解决方案可能会有所帮助。
我的问题是应用程序“依赖项”是比系统sdk工具版本更低的版本。
我们应该为您的应用程序的每个依赖项提供有关系统SDK工具版本的正确版本。
我认为Android工作室可能让我们感到困惑。该异常应与System SDK工具版本与Application依赖版本不匹配。
在我的应用程序中,依赖项之一是“support-v7”版本是24.1.1,但我的系统具有“support-v7:24.2.0”。所以我改成了最新版本。然后我的问题就解决了。