1

Error:Execution failed for task ':app:transformClassesWithDexForStagingDebug'.

com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/content/res/TypedArrayUtils;

I have seen similar questions on SO like mine , for example : Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat.

However, I have many included libraries so my dependencies output is huge and I can't figure out with dependency is causing the issue. I thought the issue was com.google.firebase:firebase-messaging:10.0.1 so I added:

compile ('com.google.firebase:firebase-messaging:10.0.1'){
        exclude module: 'support-v4'
    }

but that did not fix the issue.

I also see in my dependency output:

com.android.databinding:library:1.2.1
|    +--- com.android.databinding:baseLibrary:2.2.0-dev -> 2.2.2
|    \--- com.android.support:support-v4:21.0.3 -> 25.3.0 (*)

what does 21.0.3 -> 25.3.0 (*) mean exactly ? Does it mean my databinding library is using 21.0.3 OR 25.3.0? Does it have to be updated, if so how?

Maybe someone can look at my dependency output and point me in the right direction. Android issues like these just drive me nuts.

My dependency output

Community
  • 1
  • 1
Mike6679
  • 5,547
  • 19
  • 63
  • 108
  • Inside your dependency output, search for "support-v4". I can see multiple modules have different versions of support-v4. Exclude from all other modules and include only the latest one. – Nizam Mar 23 '17 at 06:54
  • Perform `./gradlew :app:dependencies`, search for duplicated dependency import and exclude them. – azizbekian Mar 23 '17 at 07:11
  • @Nizam which one exactly are you talking about? – Mike6679 Mar 23 '17 at 12:27

1 Answers1

0

This issue has bit me a few times now. This all started when I updated my com.android.support:support library to : -v4:25.3.0'. I think I have a good way to fix the issue:

  1. Make sure all your components are up to date i.e: "Android SDK Platform 25" etc. For me there was a balloon everytime I opened Android Studio telling me to do so and I just clicked on that:

enter image description here

  1. Then I created a new Android project (don't add any additional files / classes - this is just a shell )

  2. I then copied my library definitions from my main project's gradle file (in the dependency section) to the new project's gradle one by one. After each one I added , I tried to run the new project.

  3. Eventually you will get you original error in the new new project. For me it was this library:

    OLD: compile 'com.android.support:recyclerview-v7:+' NEW: compile 'com.android.support:recyclerview-v7:25.3.0'

Mike6679
  • 5,547
  • 19
  • 63
  • 108