Exoplayer: Cannot use ExoPlayer 2.10.0 with Android support libraries

Created on 10 May 2019  路  10Comments  路  Source: google/ExoPlayer

While 2.9.6 allowed use of the Android Support Libraries, 2.10.0 does not, producing an error during project sync:

ERROR: Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
    is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
    Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:12:5-50:19 to override.

I do not see anywhere in the release notes noting that 2.10.0 requires switching to AndroidX. We've tried to switch to AndroidX, but the automated migration tooling fails as per https://stackoverflow.com/questions/53853617/enabling-androidx-causes-cannot-change-strategy-of-configuration-appcompile -- and no one has provided a resolution to this.

question

Most helpful comment

Okay, it is understandable that from ExoPlayer's perspective this should be closed.

The corresponding bug I filed against the AndroidX migration should remain open, however, as a migration that fails for various build.gradle files with an error that provides no guidance as to how the issue can be addressed is not an acceptable path to AndroidX. There's a reason the stackoverflow query about this issue remains open -- it appears that the AndroidX migration tooling simply can't handle a good number of perfectly valid build.gradle files.

Also for ExoPlayer there really should be a clear banner in the release notes, noting that this version now requires one to have migrated to AndroidX!

All 10 comments

Hi
I confirm , with the new version 2.10.0 , there are many problem with AndroidX
i've spend hole day try to fix problem due to the migration until i give up and back to old version
and there is a problem with the sound as well discontinue when streaming
Regards

When I create a new project in Android Studio and I have these dependencies in my gradle file I receive the above error as you report it:

implementation 'com.google.android.exoplayer:exoplayer-core:2.10.0'
implementation 'com.google.android.exoplayer:exoplayer-ui:2.10.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'

Then I add the following to my gradle.properties

android.enableJetifier=true
android.useAndroidX=true

And I can build and deploy the app after having updated the import statements. I'm not sure if this works with your project as well, as it's a tiny no-op sample app only.

I found this here: https://developer.android.com/jetpack/androidx and I am using Android Studio 3.4 with the targetSdkVersion and compileSdkVersion set to 28.

@marcbaechinger As per above when I try the migration tools I run into the issue in the stackoverflow query I referenced. I filed https://issuetracker.google.com/issues/132402278 on that issue with Google.

It's working as intended that you need to use AndroidX with more recent builds of ExoPlayer. I'm not an expert on Gradle, but I think that this problem...

Cannot change strategy of configuration ':app:compile' after it has been resolved

...is most likely related to something odd about your project's gradle files. For the AppAuth-Android project I can make this error go away by removing apply from: '../config/style.gradle' from the bottom of the app's gradle file. I can make all remaining errors go away by removing this block from the library's gradle file:

apply from: '../config/style.gradle'
apply from: '../config/coverage.gradle'
apply from: '../config/javadoc.gradle'

artifacts {
    archives sourcesJar
    archives javadocJar
}

Obviously doing this loses some functionality, so what you probably have to do is figure out how to rework those pieces to be friendly with whatever the AndroidX transformation is doing. Looking at style.gradle, it seems the error is specifically related to this line:

task checkAllSource(type: Checkstyle) {
    source 'java'
    include '**/*.java'
    classpath = files project.configurations.compile.files     <----------------
}

So I wonder if you need to specify this in a different way somehow. Hopefully this gives you some new points to dig in on.

I'm going to go ahead and close this, since it's not an ExoPlayer issue. I think you'll hit this problem whenever you end up needing to switch to AndroidX, and you cannot avoid switching forever.

Okay, it is understandable that from ExoPlayer's perspective this should be closed.

The corresponding bug I filed against the AndroidX migration should remain open, however, as a migration that fails for various build.gradle files with an error that provides no guidance as to how the issue can be addressed is not an acceptable path to AndroidX. There's a reason the stackoverflow query about this issue remains open -- it appears that the AndroidX migration tooling simply can't handle a good number of perfectly valid build.gradle files.

Also for ExoPlayer there really should be a clear banner in the release notes, noting that this version now requires one to have migrated to AndroidX!

So we can not upgrade to version 2.10.0 if our project has not migrated to androidx?

Use below dependencies

implementation 'com.google.android.exoplayer:exoplayer-core:2.10.1'
implementation 'com.google.android.exoplayer:exoplayer-dash:2.10.1'
implementation 'com.google.android.exoplayer:exoplayer-ui:2.9.6'
implementation 'com.google.android.exoplayer:exoplayer-smoothstreaming:2.10.1'

So we can not upgrade to version 2.10.0 if our project has not migrated to androidx?

Only ui lib should be 2.9.6

You should not mix different versions of ExoPlayer modules. Doing so may result in incompatibility issues. Stick with 2.9.6 for everything, or update everything.

implementation 'com.google.android.exoplayer:exoplayer-core:2.10.1'
implementation 'com.google.android.exoplayer:exoplayer-dash:2.10.1'
implementation 'com.google.android.exoplayer:exoplayer-ui:2.9.6'
implementation 'com.google.android.exoplayer:exoplayer-smoothstreaming:2.10.1'

Thanks. it is working fine for me.

Was this page helpful?
0 / 5 - 0 ratings