Solution for Installation failed with message INSTALL_FAILED_CONFLICTING_PROVIDER

Brief description of the problem

    Recently, it was found that the debug package and the signature package of the project cannot coexist. The Xiaomi mobile phone prompts "conflict with the content provider of the installed application". It is also an error to run directly with studio. I took the time to take a look today and record it. 


problem causes

   From the prompt, it can be clearly seen that it is caused by the authorities in the provider of hms, the debug package and the signature package conflict, mainly when integrating Huawei Push, it is written in the Demo of Huawei Push 

<!-- Huawei mobile service configuration , replace xxx with the actual package name -->

Then I stupidly replaced it with my own package name crycry, which caused the following problems.

In Android, the authority requirement must be unique. If you install an application with a provider, the system will check whether the authority of the currently installed application is the same as the authority of the application you want to install. If it is the same, the above warning will pop up, and installation failed.

solution

    Since it must be unique, let's just make it follow applicationId, anyway applicationId must be unique.

Pass ${applicationId} in the code, it's ok to replace it 

<!-- Huawei mobile service configuration, replace xxx with the actual package name-->
        <provider
            android:name="com.huawei.hms.update.provider.UpdateProvider"
            android:authorities="${applicationId}.hms.update.provider"
            android:exported="false"
            android:grantUriPermissions="true">
        </provider>

Written at the end, the authorities in other providers can also take this solution, I hope it can help you!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324774474&siteId=291194637