Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat
Run gradle -q dependencies
(or gradle -q :projectName:dependencies
) to generate a dependency report. You should see where r7
is coming from, such as:
compile - Classpath for compiling the main sources.
+--- com.commonsware.cwac:camera-v9:0.5.4
| +--- com.actionbarsherlock:actionbarsherlock:4.4.0
| | \--- com.google.android:support-v4:r7
| +--- com.commonsware.cwac:camera:0.5.4
| \--- com.android.support:support-v4:18.0.+ -> 18.0.0
\--- com.android.support:support-v4:18.0.+ -> 18.0.0
Then, use the exclude
directive to block that dependency. In my case, it is coming from my CWAC-Camera library, and so I use:
dependencies {
compile('com.commonsware.cwac:camera-v9:0.5.4') {
exclude module: 'support-v4'
}
compile 'com.android.support:support-v4:18.0.+'
}
(where the second compile
statement indicates what version you actually want)
That should clear matters up, as you will see if you run the dependency report again:
compile - Classpath for compiling the main sources.
+--- com.commonsware.cwac:camera-v9:0.5.4
| +--- com.actionbarsherlock:actionbarsherlock:4.4.0
| \--- com.commonsware.cwac:camera:0.5.4
\--- com.android.support:support-v4:18.0.+ -> 18.0.0
Android Studio build error - Multiple dex files define Landroid/support/v4/
For anyone who is interested, I solved my own problem. My mistake was that I had pasted android-support-v4.jar and google-play-services.jar in all of my project's module lib folders (my project consists of 3 modules). What I had to do instead was to paste these jars only into my main module's lib folder, and the other modules would automatically reference them.
Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat with Gradle
The problem was in apkLib dependency and confuse msg from Gradle. It was solved like in this answer putting Android-PullToRefresh into separate android library project in Gradle.
multiple dex files define Landroid/support/v4/
the library authors should fix them
Related Topics
How to Retrieve Data from Firebase to My Adapter
How to Use External Jars in an Android Project
Open Another Application from Your Own (Intent)
Difference Between Getcontext() , Getapplicationcontext() , Getbasecontext() and "This"
Viewpager and Fragments - What's the Right Way to Store Fragment'S State
Disable Back Button in Android
Environment.Getexternalstoragedirectory() Deprecated in API Level 29 Java
Android Intent Filter: Associate App With File Extension
How to Pass Images (Bitmaps) Between Android Activities Using Bundles
Android Studio: Add Jar as Library
How to Copy Files from 'Assets' Folder to Sdcard
Get/Pick an Image from Android'S Built-In Gallery App Programmatically
What Is the List of Supported Languages/Locales on Android