Search code examples
androidandroid-studioandroid-gradle-pluginaapt2

Application icon not showing after Gradle plugin update to 3.0


I want to upgrade my Android Plugin for Gradle from 2.3.3 to 3.0.1. I could fix all the errors following the Migration Guide. My problem now is that on Android Nougat (24) and Android Marshmallow (23) application icon is replaced with the default robot icon.

Could you help me find the reason for the problem. Previously icon was shown and I don't see logical reason why not now.

I tried all suggestions here without success.

Here is my Manifest file:

<!-- 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>

Here is project Gradle file:

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" }
}
}

Solution

  • I found the problem in this Twitter post. "Android plugin 3.0.0 enables AAPT2 by default" as explained in the Migration guide. Looks like that this change causes problems with the resources.

    To fix application's icon I had to disable the use of Aapt2 by adding android.enableAapt2=false in gradle.properties file.

    NOTE: I could NOT reproduce the problem when I created new application with the same gradle setup.