代码之家  ›  专栏  ›  技术社区  ›  masiboo

添加外部库后AndroidManifest.xml中的应用图标问题

  •  0
  • masiboo  · 技术社区  · 6 年前

    我发现了类似的问题@ Android studio Gradle icon error, Manifest Merger .

    但这些建议都不适合我。我使用的是androidstudio3.2。在我的应用程序中,我使用app->建造。gradle:-

     apply plugin: 'com.android.application'
    
    
        android {
            compileSdkVersion 25
            buildToolsVersion '28.0.2'
            defaultConfig {
                applicationId "com.home.ma.photolocationnote"
                minSdkVersion 16
                targetSdkVersion 27
                versionCode 6
                versionName "6.0"
                multiDexEnabled = true
                testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
            }
            buildTypes {
                release {
                    minifyEnabled false
                    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                }
            }
            compileOptions {
                targetCompatibility 1.8
                sourceCompatibility 1.8
            }
        }
    
        dependencies {
            implementation fileTree(dir: 'libs', include: ['*.jar'])
            androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
                exclude group: 'com.android.support', module: 'support-annotations'
            })
            implementation 'com.android.support:appcompat-v7:25.0.0'
            implementation 'com.android.support:design:25.0.0'
            implementation 'com.android.support.constraint:constraint-layout:1.0.2'
            implementation 'com.microsoft.azure.android:azure-storage-android:2.0.0@aar'
            implementation 'javax.xml.stream:stax-api:1.0-2'
            implementation 'org.apache.commons:commons-lang3:3.0'
            implementation 'com.google.firebase:firebase-core:16.0.1'
            implementation 'com.google.android.gms:play-services-analytics:16.0.0'
            implementation 'com.google.android.gms:play-services-maps:15.0.1'
            implementation 'com.google.android.gms:play-services-location:15.0.1'
            implementation 'com.google.android.gms:play-services-gcm:15.0.1'
           // after adding this lib
            implementation 'com.microsoft.azure:notification-hubs-android-sdk:0.4@aar'
            // after adding this lib 
            implementation 'com.microsoft.azure:azure-notifications-handler:1.0.1@aar' 
    
            testImplementation 'junit:junit:4.12'
        }
    

    项目->内部版本.gradle:-

      buildscript {
            repositories {
                jcenter()
                google()
                mavenCentral()
            }
            dependencies {
                classpath 'com.android.tools.build:gradle:3.2.0'
                classpath 'com.google.gms:google-services:4.0.1'
    
                // NOTE: Do not place your application dependencies here; they belong
                // in the individual module build.gradle files
            }
        }
    
        allprojects {
            repositories {
                jcenter()
                google()
                mavenCentral()
            }
        }
    
        task clean(type: Delete) {
            delete rootProject.buildDir
        }
    

    清单合并失败,出现多个错误,请参阅日志

    xmlns:tools="http://schemas.android.com/tools“还有tools:replace="android:icon,android:theme,android:label,android:name"

    这是我的AndroidManifest。xml:-

     <?xml version="1.0" encoding="utf-8"?>
        <manifest 
    xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            package="com.home.ma.photolocationnote">
    
            <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
            <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
            <uses-permission android:name="android.permission.INTERNET" />
            <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
            <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
            <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    
            <permission
                android:name="com.home.ma.photolocationnote.permission.MAPS_RECEIVE"
                android:protectionLevel="signature" />
    
            <uses-permission android:name="com.home.ma.photolocationnote.permission.MAPS_RECEIVE" />
            <uses-permission android:name="com.google.android.providers.gsf.permisson.READ_GSERVICES" />
    
            <supports-screens
                android:largeScreens="true"
                android:normalScreens="true"
                android:smallScreens="true"
                android:xlargeScreens="true" />
    
            <uses-feature
                android:glEsVersion="0x00020000"
                android:required="true" />
    
            <application
                tools:replace="android:icon,android:theme,android:label,android:name"
                android:allowBackup="true"
                android:icon="@mipmap/app_icon" // I tried "@drawable/app_icon" also.  
                android:label="@string/app_name"
                android:largeHeap="true"
                android:supportsRtl="true"
                android:theme="@style/AppTheme">
                <meta-data
                    android:name="com.google.android.geo.API_KEY"
                    android:value="xxxxxxxxx" />
    
                <activity
                    android:name=".MainActivity"
                    android:label="@string/app_name"
                    android:theme="@style/AppTheme.NoActionBar"></activity>
    
                <meta-data
                    android:name="com.google.android.gms.vision"
                    android:value="@integer/google_play_services_version" />
    
    
                <activity
                    android:name=".MapsActivity"
                    android:label="@string/title_activity_maps"
                    android:theme="@style/AppTheme.NoActionBar">
                    <intent-filter>
                        <action android:name="android.intent.action.MAIN" />
    
                        <category android:name="android.intent.category.LAUNCHER" />
                    </intent-filter>
                </activity>
                <activity android:name=".CameraActivity" />
                <activity
                    android:name=".NoteEditorActivity"
                    android:label="@string/title_activity_note_editor"
                    android:theme="@style/AppTheme.NoActionBar" />
    
                <provider
                    android:name=".contentProvider.NoteContentProvider"
                    android:authorities="authorities.photolocationnote.contentprovider"
                    android:exported="true" />
    
                <activity
                    android:name=".NoteListActivity"
                    android:label="@string/title_activity_note_list"
                    android:theme="@style/AppTheme.NoActionBar" />
    
            </application>
    
        </manifest>
    

    错误msg:-

    也出现在[com.microsoft.com.cn上。azure:azure-notifications-handler:1.0.1]AndroidManifest。xml:13:9-45值=(@drawable/ic\u launcher)。 建议:添加'tools:replace="android:icon“'到AndroidManifest中的元素。xml:29:5-76:19以覆盖。

    1 回复  |  直到 6 年前
        1
  •  1
  •   Ümañg ßürmån    6 年前

    解决方案:

    从以下位置更改应用程序标记:

    <application
            tools:replace="android:icon,android:theme,android:label,android:name"
            android:allowBackup="true"
            android:icon="@mipmap/app_icon" // I tried "@drawable/app_icon" also.  
            android:label="@string/app_name"
            android:largeHeap="true"
            android:supportsRtl="true"
            android:theme="@style/AppTheme">
    

    对此:

    <application
            android:allowBackup="true"
            android:icon="@mipmap/app_icon" 
            android:label="@string/app_name"
            android:largeHeap="true"
            android:supportsRtl="true"
            android:theme="@style/AppTheme"
            tools:replace="android:icon">
    

    试试看,希望有帮助。