如何解决添加 ExpoPlayer 依赖项后的错误



我想使用Google ExoPlayer,但是当我添加此依赖项时

implementation 'com.google.android.exoplayer:exoplayer:2.10.4'

到我的依赖项,我收到了此错误.

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.1] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:8:5-26:19 to override.

我也在清单中的应用程序标签中添加了tools:replace="android:appComponentFactory",但没有工作。 我该怎么办?

原因是您使用的是旧版本的支持库。您需要迁移到 AndroidX 或在 gradle.properties 文件中添加以下行。

android.useAndroidX=true
android.enableJetifier=true

在清单中添加

<application
...
tools:replace="android:appComponentFactory">

如果您使用的是 andoidx,请在下面添加两行gradle.properties

android.useAndroidX=true
android.enableJetifier=true

最新更新