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'
}
}