2015-04-17 78 views
0

我已经从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') 
    } 
} 
+0

只需将其删除即可。如果你已经有一个使用这个依赖项的库项目,它应该在你添加该库的依赖项时被选中 –

+0

[多个dex文件在android studio中定义Landroid/support/v4 /]的可能重复(http://stackoverflow.com/questions/23264223/multiple-dex-files-define-landroid-support-v4-in-android-studio) –

+0

检查jar的版本是否相同。例如,当你导入库时,如果同一个jar在两个库中,则复制一个并粘贴到其他库中。它会要求更换选项。请点击是 – Hulk

回答

5

添加支持jar只有在库项目。无需将其添加到主项目中,并牢记所有支持库应该具有相同版本

+0

谢谢。根据您提供的答案,我删除了该项目的gradle文件中的支持库,问题已解决。直到最近一次Android SDK更新才有问题。 – Hong