2

I got "Error converting bytecode to dex" in a Chromecast project with Remote Display API. I solved this by adding "multiDexEnabled true", but this only generated another error:

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzlg.class

I have checked my Gradle files, but I can not find any conflict. I read other similar threads and tried their code fixes, but no use here. How can I proceed with this?These are my gradle files:

Gradle files

2 Answers2

2

First, try to clean/rebuild the project because usually that kind of error will be gone after you clean/rebuild the project.

From this documentation, when you add multiDexEnabled true in the gradle.files, make sure you also add compile 'com.android.support:multidex:x.x.x' in the dependencies.

For more information, check these related SO questions:

Community
  • 1
  • 1
KENdi
  • 7,576
  • 2
  • 16
  • 31
0

You may be compiling the same dependency multiple times. For example, play-services-cast depends on appcompat-v7. You can prevent recompiling the same dependency with:

compile ('com.google.android.gms:play-services-cast:8.3.+')
{
    exclude group: 'com.android.support', module: 'appcompat-v7'
}

Use the shell command gradlew -q YourApp:dependencies to print your app's dependency graph; then in your build.gradle, exclude dependencies that show up multiple times.

plátano plomo
  • 1,672
  • 1
  • 18
  • 26