android 图标名称资源被第三方库替换

开源组件使用越来越多,有时发现自己应用图标,主题,名字都会变成一个谋明其妙的东西,这是因为

引入的第三方库里面也有自己的application名字定义了和我们app相同名字的icon,label和主题,这导致,我们使用的资源变成了

第三方库的,下面有一个解决方案:

在app的AndroidManifest.xml中做如下修改:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="xxx"
    android:versionCode="1"
    android:versionName="1.0">

    <application
        android:allowBackup="true"
        android:icon="@drawable/my_ic_launcher"//改成唯一的名字
        android:label="@string/my_app_name"//改成唯一的名字
        android:theme="@style/myAppTheme"//改成唯一的名字
        tools:replace="android:icon, android:theme,android:label">//添加要替换的资源
<provider
            android:name="android.support.v4.content.FileProvider"
            android:authorities="com.data.cloudminds.disk.fileprovider"
            android:exported="false"
            android:grantUriPermissions="true"
            tools:replace="android:authorities">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_paths"
                tools:replace="android:resource" />
        </provider>

注意:

1. 在manifest节点加上:xmlns:tools="http://schemas.android.com/tools"

2. 在application 节点加上:tools:replace="android:icon, android:theme,android:label"

3.在application里面将我们的资源名改成和第三方库不同

发布了92 篇原创文章 · 获赞 27 · 访问量 9万+

猜你喜欢

转载自blog.csdn.net/zhuxingchong/article/details/88866458
今日推荐