我已經從eclipse導出項目 - 但現在我不能將支持庫添加到我的項目compile 'com.android.support:support-v4:21.0.0'
因爲在這個項目中使用的庫有他們自己的同一個庫的副本(但他們在他們的libs
文件夾中的jar文件中)。現在,當我加入compile 'com.android.support:support-v4:21.0.0'
我得到這個問題:多支持v4瓶子導致問題
Error:Execution failed for task ':Athan:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: android/support/annotation/IntDef.class
有人可以幫助我解決這個問題?
這是我的應用程序的build.gradle
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':google-play-services_lib')
compile project(':library_viewpager')
compile project(':sliding_library')
compile project(':android-support-v7-appcompat')
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:support-v4:21.0.0'
}
android {
compileSdkVersion 21
buildToolsVersion "22.0.1"
dexOptions {
preDexLibraries = false
}
defaultConfig {
multiDexEnabled true
}
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')
}
}
只需將其刪除即可。如果你已經有一個使用這個依賴項的庫項目,它應該在你添加該庫的依賴項時被選中 –
[多個dex文件在android studio中定義Landroid/support/v4 /]的可能重複(http://stackoverflow.com/questions/23264223/multiple-dex-files-define-landroid-support-v4-in-android-studio) –
檢查jar的版本是否相同。例如,當你導入庫時,如果同一個jar在兩個庫中,則複製一個並粘貼到其他庫中。它會要求更換選項。請點擊是 – Hulk