项目场景:
为了图方便,把一个项目直接把文件夹复制一个,把包名这些改了下就继续写了,结果在应用运行调试时出现错误。
问题描述:
安装程序时会报以下错误
Session 'app': Installation did not succeed.
The application could not be installed: INSTALL_FAILED_CONFLICTING_PROVIDER
网上查了一下,发现大概是虽然包改了,但AndroidManifest.xml中配置的provider的android:authorities和其他的应用相同。我自己这边AndroidManifest.xml里是没有的,所以在里加上,如下:
<provider
android:authorities="com.example.app1.my_provider"
android:name="androidx.core.content.FileProvider"/>
其中authorities就写自己的包名+你给这个provider取得名字就行了。
结果我还是报错
根据提示再加上一行tools:replace="android:authorities"就行了
<provider
tools:replace="android:authorities"
android:authorities="com.example.app1.my_provider"
android:name="androidx.core.content.FileProvider"/>