3

Running Android Studio 3.2 RC3. Tried upgrading an old project to use androidx. Got most of it working, but I keep getting the error below.

java.lang.RuntimeException: com.android.build.api.transform.TransformException: Error while generating the main dex list. com.android.build.api.transform.TransformException: Error while generating the main dex list. com.android.builder.multidex.D8MainDexList$MainDexListException: com.android.tools.r8.errors.CompilationError: Program type already present: android.support.v4.media.MediaBrowserCompat$CallbackHandler
com.android.tools.r8.errors.CompilationError: Program type already present: android.support.v4.media.MediaBrowserCompat$CallbackHandler

I have these properties set in gradle.properties:

android.useAndroidX=true
# Tried both false and true...
android.enableJetifier=false

The following line in my app.gradle seems to be the culprit:

implementation 'androidx.mediarouter:mediarouter:1.0.0'

Obviously, I need the classes from that library so I can't remove it.

Update

External libraries shows this suspicious dependency:

Gradle: androidx.media:media-1.0.0
  classes.jar
    android.support.v4.media
      MediaBrowserCompat
      MediaBrowserCompatApi21
      MediaBrowserCompatApi23
      MediaBrowserCompatApi26

Why this dependency?

l33t
  • 18,692
  • 16
  • 103
  • 180
  • `Error while generating the main dex list` Is multidex enabled ? – ʍѳђઽ૯ท Sep 22 '18 at 21:45
  • Yes. I tried to disable it, but no difference for this particular class. – l33t Sep 22 '18 at 22:05
  • Can we see your `Build.gradle`? Please edit the question and paste the contents of it in the question. – ʍѳђઽ૯ท Sep 22 '18 at 22:07
  • I don't think the gradle will help in this case (tried creating a minimum project using the same settings, but it works). Most puzzling is that "Rebuild All" works, but then if I choose "Make Project" it gives me this error. Even if I turn off multi-dexing. – l33t Sep 24 '18 at 07:10
  • I answered it [here](https://stackoverflow.com/a/52560036/6570945). Hope it works for you. – Ashu Tyagi Sep 28 '18 at 17:32
  • Did you solve this issue? I have the same error. – IgorGanapolsky Aug 20 '19 at 00:38
  • I think the error disappeared after updating all dependencies that referenced some old version of the Support Library. – l33t Aug 20 '19 at 07:37

0 Answers0