Error assembling ExoPlayer v2.4.0 with Google Play Services
Errors assembling ExoPlayer v2.4.0 together with Google Play Services.
Configuration example:
compile 'com.google.android.gms:play-services-ads:10.2.0'
compile 'com.google.android.exoplayer:exoplayer:r2.4.0'
I guess, the problem is that exoplayer uses "com.android.support:support-annotations:25.3.1" while play-services uses "com.android.support:support-v4:24.0.0", which are not compatible.
Error log assembling in Debug mode:
Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
...
Error log assembling in Release mode:
Warning:Exception while processing task java.io.IOException: Can't write
[C:\Users\...\app\build\intermediates\transforms\proguard\release\jars\3\1f\main.jar]
(Can't read [C:\Users\...\.android\build-cache\7240ae15...6b07e16\output\jars\classes.jar(;;;;;;**.class)]
(Duplicate zip entry [android/support/a/a/ac.class == classes.jar:android/support/v4/app/NotificationCompat.class]))
Removing play-services solves the issue.
With v2.3.1 there is no such issue.
They are compatible, it's just that gradle isn't clever enough to figure it out. You can resolve the problem by amending your example to explicitly also depend on the most recent version of com.android.support:support-v4, like:
compile 'com.google.android.gms:play-services-ads:10.2.0' compile 'com.google.android.exoplayer:exoplayer:r2.4.0' compile 'com.android.support:support-v4:25.3.1'
The need to do this is a side effect of the modularization of the Android support library, and is necessary if you end up depending (directly or transitively) on both a pre-modularization version of the support library and one or more of the individual modules from a post-modularization version. In this scenario gradle doesn't have enough information to correctly resolve the dependencies.
The first modularized version was 24.2.0, so the workaround wont be necessary once play-services-ads updates to depend on a version greater than that.