错误 INSTALL_FAILED_CONFLICTING_PROVIDER 我的应用程序没有任何提供商

Error INSTALL_FAILED_CONFLICTING_PROVIDER without any provider on my app

我收到这个错误:

INSTALL_FAILED_CONFLICTING_PROVIDER - multiple apps using same authority provider name

但是我的应用程序上没有任何提供程序,然后我注意到最后的 AndroidManifest.xml 有以下提供程序:

    <provider
        android:name="com.google.android.gms.measurement.AppMeasurementContentProvider"
        android:authorities="com.google.android.gms.measurement.google_measurement_service"
        android:exported="false" />

这似乎是最新 Google Play 服务库中的 analytics issue

解决方案是在 build.gradle 上添加一个 applicationId 设置:

defaultConfig {
    applicationId "your.package.name"
}

首先,您在上面看到的错误消息仅当您要在同一设备上安装相同的应用程序实例时才会出现。

flavors {
   prod {
     applicationId "your.package.name.prod"
   }
   qa {
     applicationId "your.package.name.qa"
   }
}

从错误消息中您可以清楚地识别问题,这是由于您的 AndroidManifest.xml 文件中的提供程序标记引起的。

Solution: 1. Identify which provider tag is causing the issue. 2. Most probably the issue could be android:authroties field. 3. Extend the same provider in your AndroidManifest.xml and add tools:merge="${applicationId}.some.string" field

基本上,您的所有应用程序 apk 中都应该有一个唯一的提供商名称 (android:authroties)。