Search code examples
androidandroid-manifestandroid-launcher

Android application is installing two launcher icons


This is not a duplicate of Android Application creating two launcher icons (I don't have multiple LAUNCHER definitions in my manifest), nor Android Application Creating Two Launcher Icons instead of One (a restart of the device does not remove the second launcher icon).

My android application is creating two launcher icons, but one of them seems to be coming from the application itself, rather than any activity. I've cropped my AndroidManifest.xml to the smallest it can be (plus clean and rebuild and reinstall), and I am still getting two icons (on both my HTC One M8 physical phone and my Nexus 5 emulator):

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.app">

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

        <activity
            android:name=".SplashActivity"
            android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

There is nothing else in my manifest.

...does the application itself as I've defined it create an icon somehow? Or is there some other way that I'm ending up with multiple launcher icons?

If I move the android:label and android:icon features into the .SplashActivity definition, one of the launcher icons created is replaced with the default little green robot icon.


Solution

  • Activities and other bits of manifest-y goodness come from a variety of sources:

    • the manifest in your main sourceset
    • the manifest in any build type or product flavor sourceset
    • the manifest in any library module or AAR
    • Gradle (e.g., minSdkVersion)

    Android Studio 2.2 gave us a convenient tool to examine the real manifest that goes into our APKs, merged from all those sources. If you open the manifest in Android Studio, click over on the "Manifest Merger" sub-tab (towards the bottom of the IDE). That will show what is in the merged manifest and who is to blame for it where it came from.

    If you see other activities in there besides the one in your manifest, that is the source of your launcher icon. Then, you'll need to decide:

    • is that activity something you really want?
    • if not, is the source of that activity something that you really want? (if not, nuke it)
    • if you want the source but not the activity, you can rig up another activity element in your manifest, with a tools:replace attribute, to override the one from the library and suppress the <intent-filter>