INSTALL FAILED CONFLICTING PROVIDER问题完美解决方案
来源:互联网 发布:一辈子单身感受知乎 编辑:程序博客网 时间:2024/06/05 18:35
在安装Android应用时出现INSTALL FAILED CONFLICTING PROVIDER
问题,是不是感觉很抓狂呢,下面就跟大家分享一下出现这个问题的原因及解决方案。
问题原因
在Android中authority
要求必须是唯一的,比如你在定义一个provider
时需要为它指定一个唯一的authority
。如果你在安装一个带有provider
的应用时,系统会检查当前已安装应用的authority
是否和你要安装应用的authority
相同,如果相同则会弹出上述警告,并且安装失败。
解决方案
在定义provider
是,使用软编码的形式,如下:
<provider android:name="android.support.v4.content.FileProvider" android:authorities="${applicationId}.fileprovider" android:grantUriPermissions="true" android:exported="false"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" /></provider>
上述代码中通过${applicationId}.fileprovider
的形式来指定provider
的authorities
,所以该provider
的authorities
会根据applicationId
的不同而不同,从而避免了authorities
的冲突问题。
那么如何使用刚才定义的authorities
呢?
我们在定义authorities
是采用了applicationId+fileprovider的形式,在获取authorities
的时候,我们就可以通过包名+fileprovider来获取,代码如下:
public final static String getFileProviderName(Context context){ return context.getPackageName()+".fileprovider";}
最后
既然来了,留下个喜欢再走吧,鼓励我继续创作(^_^)∠※
如果喜欢我的文章,那就关注我的博客吧,让我们一起做朋友~~
戳这里,加关注哦:
微博:第一时间获取推送
个人博客:干货文章都在这里哦
GitHub:我的开源项目
4 0
- INSTALL FAILED CONFLICTING PROVIDER问题完美解决方案
- INSTALL FAILED CONFLICTING PROVIDER问题完美解决方案
- Android INSTALL FAILED CONFLICTING PROVIDER错误
- install failed with message INSTALL_FAILED_CONFLICTING_PROVIDER 解决方案
- Failed to import Gradle project完美解决方案
- 解决Eclipse插件升级中Cannot complete the install because of a conflicting dependency的问题
- 解决Eclipse插件升级中Cannot complete the install because of a conflicting dependency的问题
- 解决Eclipse插件升级中Cannot complete the install because of a conflicting dependency的问题
- 解决Eclipse插件升级中Cannot complete the install because of a conflicting dependency的问题
- JBulder中文问题完美解决方案
- GWT中文问题完美解决方案
- ADT在eclipse中重装时的问题--Cannot complete the install because of a conflicting dependency
- 解决方案:Failed to install helloworld.apk on device 'emulator-5554'
- 解决方案:Failed to install *.apk on device 'emulator-5554'
- Failed to install HelloWorld.apk on device 'emulator-5554! 解决方案
- 关于“The underlying provider failed on Open”的问题
- centos install python 问题及解决方案
- JBuilder中文问题完美解决方案(转)
- 缺少函数标题(是否是老式的形式表?)
- 不让视图延展到状态栏
- 数组
- Leetcode 415 Add Strings
- Java多线程(3):使用Condition中的await、signal进行线程间协作
- INSTALL FAILED CONFLICTING PROVIDER问题完美解决方案
- adb install 安装apk过程中报错Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE]
- es 语句
- Promise/A+规范
- 《自制编译器》中cbc在ubuntu64位上的简单用法
- |洛谷|NOIP2010|搜索|贪心|P1514 引水入城
- Linux vim gedit id
- SharpMap渐变色填充多边形
- OpenWrt添加DDNS服务提供商(花生壳)的方法