Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merging android manifest files, conflicting filter

I'm trying to combine android manifest files from 2 plugins in Unity, but there are two activities with the same intent-filter and I can only get 1 or the other to work at the same time....

Of the 2 conflicting activities, whichever is on top in the manifest file is the one that will work. So if activity from manifest #1 is on top, plugin #1 will work but not #2, and vice versa.

The two conflicting activities are:

<activity
        android:name="com.devfo.andutils.DevfoUnityPlayerActivity"
        android:label="@string/app_name"
        android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
        android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
    </activity> 

And:

<activity android:name="com.qualcomm.QCARUnityPlayer.QCARPlayerProxyActivity" 
android:label="@string/app_name" android:screenOrientation="portrait" 
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
  <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
  </intent-filter>
</activity>

is there any way I can merge the two and get them to work from the same app? I'm using Unity 3d.

like image 366
user1108224 Avatar asked Nov 05 '13 17:11

user1108224


People also ask

How do you do merged manifest?

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 an AndroidManifest file?

The manifest file describes essential information about your app to the Android build tools, the Android operating system, and Google Play.

How can manifest file can be edited in Android?

Open your Android project and go to <AppProjectFolder>/app/src/main/. Open the app manifest file AndroidManifest. xml and add the following lines to the file as child elements of the <manifest> element. Note: You must include the QUERY_ALL_PACKAGES permission if your app targets Android 11 (API Level 30) or higher.

Where are Android manifest files stored?

The file is located at WorkspaceName>/temp/<AppName>/build/luaandroid/dist. The manifest file provides essential information about your app to the Android operating system, and Google Play store. The Android manifest file helps to declare the permissions that an app must have to access data from other apps.


2 Answers

For example in the manifest where you want to use only the first activity as launcher you have to add this 2 modifications:

At the beginning of the manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

And for the activity for which you want to remove the intent filter add this code:

<activity android:name="com.qualcomm.QCARUnityPlayer.QCARPlayerProxyActivity" 
android:label="@string/app_name" android:screenOrientation="portrait" 
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
  <intent-filter tools:node="removeAll">
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
  </intent-filter>
</activity>

The important part is to add the tools:node="removeAll" attribute in the intent-filter tag

like image 69
amarkovits Avatar answered Nov 15 '22 08:11

amarkovits


Declare your manifest header like this:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

And then add one of the following appropriate attributes to the relevant Activity(s):

tools:merge="override"
tools:merge="remove"
like image 43
swooby Avatar answered Nov 15 '22 07:11

swooby