Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android manifest merging: removing LAUNCHER intent-filter doesn't take effect

In my android app I use a library project and I use one of it's activities. However in the library project that activity has MAIN action and LAUNCHER category intent-filter. So I added that activity to my manifest and removed the intent-filter. The manifests seem to be correctly merged into build/intermediates/manifests/full/debug/AndroidManifest.xml, and the activity looks as expected (without the intent-filter):

    <activity
        android:name="com.michaelrnovak.util.logger.Logger"
        android:configChanges="orientation"
        android:label="@string/show_log" >
    </activity>

However when I start the app from AndroidStudio in the emulator, then instead of my AlertsActivity, the library's Logger activity is launched. What am I doing wrong?

This is the manifest of the library:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.michaelrnovak.util.logger"
      android:versionCode="8"
      android:versionName="1.5">
    <uses-permission android:name="android.permission.READ_LOGS" />
    <application
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">
        <activity android:name=".Logger"
                  android:label="@string/app_name"
                  android:configChanges="orientation">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
    <uses-sdk android:minSdkVersion="7" />
</manifest> 

and my app's manifest has the following relevant activity definitions:

    <activity
        android:name=".AlertsActivity"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:label="@string/app_name"
        android:launchMode="singleTop" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />          </intent-filter>
    </activity>
    <activity android:name="com.michaelrnovak.util.logger.Logger"
        android:label="@string/show_log"
        android:configChanges="orientation"
        tools:replace="android:label"
        >
        <intent-filter tools:node="removeAll" />
    </activity>
like image 1000
Gavriel Avatar asked Jul 07 '15 07:07

Gavriel


People also ask

How do I fix manifest merger failed?

Try adding the following labels to resolve the issue: Add the xmlns:tools line in the manifest tag. Add tools:replace= or tools:ignore= in the application tag.

How do I fix manifest merger failed apps targeting Android 12?

If you got this messages from your android studio, in your main activity add in android:exported=”false” or android:exported=”true” will solved this issue.

How can you tell if a manifest is merged?

Even before you build your app, you can see a preview of what your merged manifest looks by opening your AndroidManifest. xml file in Android Studio, and then clicking the Merged Manifest tab at the bottom of the editor.

What is the significance of intent filter element in manifest file?

An intent filter is an expression in an app's manifest file that specifies the type of intents that the component would like to receive. For instance, by declaring an intent filter for an activity, you make it possible for other apps to directly start your activity with a certain kind of intent.


1 Answers

Have you tried tools:node="remove" on the category node only? From my experience, it seems to work.

Something like this:

<activity android:name="com.michaelrnovak.util.logger.Logger"
        android:label="@string/show_log"
        android:configChanges="orientation"
        tools:replace="android:label"
        >
        <intent-filter>
            <category   tools:node="remove" android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
like image 147
Samuil Yanovski Avatar answered Sep 19 '22 03:09

Samuil Yanovski