2017-12-18 329 views
1

我想將我的Android Android插件從2.3.3升級到3.0.1。我可以修復Migration Guide之後的所有錯誤。我現在的問題是,Android Nougat(24)和Android Marshmallow(23)應用程序圖標被替換爲默認的機器人圖標。將Gradle插件更新至3.0後未顯示應用程序圖標

你能幫我找出問題的原因嗎?以前的圖標顯示,我不明白爲什麼現在不合邏輯的原因。

我試過所有建議here沒有成功。

這裏是我的清單文件:

<!-- Permissions --> 
<uses-permission android:name="android.permission.INTERNET" /> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
... 

<application 
    android:name="...Application" 
    android:allowBackup="false" 
    android:allowTaskReparenting="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/application" 
    android:largeHeap="true" 
    android:roundIcon="@mipmap/ic_launcher_round" 
    android:theme="@style/Theme.MyTheme" 
    tools:replace="android:icon,theme,label,allowBackup"> 

<uses-library android:name="com.google.android.maps" /> 

    <activity 
     android:name="...SplashActivity" 
     android:label="@string/application" 
     android:theme="@style/Theme.Splash"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 

    </activity> 

... 


</application> 

這裏是項目搖籃文件:

buildscript { 
ext.kotlinVersion = '1.2.10' 
repositories { 
    jcenter() 
    google() 
} 

dependencies { 
    classpath 'com.android.tools.build:gradle:3.0.1' 
    classpath 'com.google.gms:google-services:3.1.0' 
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" 
} 
} 

allprojects { 
ext { 
    androidApplicationId = 'myapp.android' 
    androidVersionCode = 1 
    androidVersionName = "1.0" 
    testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner" 
} 

repositories { 
    maven { url "https://maven.google.com" } 
} 
} 
+0

你檢查了什麼是可用的資源對這個值'ic_launcher_round' –

+0

我更新了我的android studio沒有你的問題,我認爲你應該清理你的項目。 – salman

+0

@AbdulWaheed我檢查了圖標,他們是我的應用程序圖標按預期。 –

回答

1

Android系統絕不會顯示應用程序,直到圖標你做。

使用tools:replace="attr"就像您在此處所做的那樣 - >tools:replace="android:icon,..."將替換優先級較高的清單中的圖標,並將圖標保留在優先級較低的清單中。

+0

在清單合併期間需要使用「替換」來解決衝突。這裏是解釋問題:https://stackoverflow.com/questions/24506800/android-studio-gradle-icon-error-manifest-merger –

+0

@MarioKutlev也許如果你有一個子項目中的子資源相同的名稱( ic_launcher)在你的依賴中實現將會發生這個問題。 隨機的解決方案是重命名啓動器圖標。 – Ibrahim

+0

我試過重命名ic_launcher,但沒有幫助。 :( –

0

我在這Twitter post發現問題。 「在Android插件3.0.0默認情況下啓用AAPT2」,如Migration guide中所述。看起來這個改變會導致資源問題。

要修復應用程序的圖標,我必須通過在gradle.properties文件中添加android.enableAapt2=false來禁用Aapt2。

注意:當我使用相同的gradle設置創建新的應用程序時,我無法重現該問題。

相關問題