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

how to resolve error after adding ExpoPlayer dependency

我想使用 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