我已经在这个问题上工作了几个小时但找不到解决方案。从stackoverflow尝试了很多答案,但没有运气。
运行应用程序时,我得到的是以下gradle错误:
:app:packageAllDebugClassesForMultiDex FAILED
Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: android/support/v4/widget/SearchViewCompatIcs$MySearchView.class
当我将 ShareThis Sdk 的依赖项添加到gradle中时,Android工作室会抛出错误。这是完整的gradle:
apply plugin: 'com.android.application'
android {
signingConfigs {
config {
keyAlias 'Alies'
keyPassword 'password'
storeFile file('path.jks')
storePassword 'password'
}
}
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "example.com.app"
minSdkVersion 10
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
preDexLibraries = false
incremental true
}
//configurations { all*.exclude group: 'com.android.support', module: 'support-v4' }
//configurations { all*.exclude module: 'support-v4' }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
provided files('libs/universal-image-loader-1.9.3.jar')
compile project(':library-circular')
compile('com.android.support:appcompat-v7:22.2.0') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile project(':sliding_library1')
compile('com.google.android.gms:play-services:7.5.0') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile project(':sdk')
}
非常感谢小帮助。
答案 0 :(得分:0)
似乎问题出在Compile independent modules in parallel (may require larger heap size)。因此,禁用该选项并清除重建应修复它。
看起来Android构建工具for multidex 有时尝试在两个dex文件中包含lib项目,它会导致一些冲突然后同时编译。
答案 1 :(得分:0)
所以,问题已经解决了。实际上 support-v4
jar文件之间存在冲突,所以我只是在任何地方使用相同的 support-v4.jar
,问题就解决了。