Multiple dex files define ... with Gradle

when i tried build a project witn a new dependencies,i see the following error

Execution failed for task ':PhotoAccess:dexDebug'.  
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
      /Applications/Android Studio.app/sdk/build-tools/19.0.1/dx --dex --output 

    Error Code:
      2
  Output:
      UNEXPECTED TOP-LEVEL EXCEPTION:
      com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;

anser:

In window :executed  gradlew --gui command to open gradle gui ,in mac or linux executed ./gradlew --gui (information:u need to root directory) and then

I select a directory from setup and executed  -q dependencies from the command line

 and the output was:

compile - Classpath for compiling the main sources.  
+--- com.android.support:appcompat-v7:+ -> 19.0.1
|    \--- com.android.support:support-v4:19.0.1
+--- com.path:android-priority-jobqueue:1.0
|    \--- com.google.android:android:2.2.1 -> 4.1.1.4
|         +--- commons-logging:commons-logging:1.1.1
|         +--- org.apache.httpcomponents:httpclient:4.0.1
|         |    +--- org.apache.httpcomponents:httpcore:4.0.1
|         |    +--- commons-logging:commons-logging:1.1.1
|         |    \--- commons-codec:commons-codec:1.3
|         +--- org.khronos:opengl-api:gl1.1-android-2.1_r1
|         +--- xerces:xmlParserAPIs:2.6.2
|         +--- xpp3:xpp3:1.1.4c
|         \--- org.json:json:20080701
+--- de.greenrobot:eventbus:2.2.0
\--- de.greenrobot:greendao:1.3.0
     +--- com.google.android:annotations:4.1.1.4
     +--- com.google.android:android:4.1.1.4 (*)
     +--- com.google.android:android-test:4.1.1.4
     |    +--- com.google.android:android:4.1.1.4 (*)
     |    \--- junit:junit:3.8.2
     \--- com.google.android:support-v4:r7

The problem was com.android.support:appcompat-v7:19.0.1 pulled in com.android.support:support-v4:19.0.1 and de.greenrobot:greendao:1.3.0 pulled in com.google.android:support-v4:r7. There are two versions (19.0.1 and r7) of a same module. I need to exclude one of them.

You can exclude a module with exclude module: statement in compile block.

dependencies {  
    compile 'com.android.support:appcompat-v7:+'
    compile 'com.path:android-priority-jobqueue:1.0'
    compile 'de.greenrobot:eventbus:2.2.0'
    compile('de.greenrobot:greendao:1.3.0') {
        exclude module: 'support-v4'
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值