0
\$\begingroup\$

I created an apk in Unity (4.6) and when I install that apk on the device it creates 2 instances of the game (2 icons are visible in the screen). Both icons start the same game, and when I uninstall the game it removes both icons.

In previous builds this didn't happen, so I'm assuming that the changes I made to the Android Manifest have something to do with it. I included the Game Analytics SDK and it caused some problems when I tried to build the game for Android (with the message that the incompatible manifests can't be merged). So I commented out the part of the manifest that was causing the problem and now I have the problem with multiple instances of the game. I did some research and found that this happens when there are multiple activities in the manifest that are marked as LAUNCHER - this is not the case in my app, only one activity has that property. Also, as far as I can see, there is only one AndroidManifest.xml file in the Unity project (only one appears when I type it in the search).

This is the part of the manifest that I needed to change:

 <activity android:name="com.unity3d.player.UnityPlayerActivity" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
</activity>
<!--<activity android:name="com.unity3d.player.UnityPlayerNativeActivity" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
  <meta-data android:name="android.app.lib_name" android:value="unity" />
  <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
</activity>-->

If the commented out part is included, Unity throws the "incompatible manifest merge" error in the building process:

Error: [Temp\StagingArea\AndroidManifest-main.xml:4, [MyGame]Temp\StagingArea\android-libraries\unityads\AndroidManifest.xml:19] Trying to merge incompatible /manifest/application/activity[@name=com.unity3d.player.UnityPlayerNativeActivity] element:

UnityEditor.HostView:OnGUI()

Did anyone have any similar problems and how did you fix it?

Thanks

\$\endgroup\$
  • \$\begingroup\$ See stackoverflow.com/a/4620410/1816262 \$\endgroup\$ – OMGtechy Mar 15 '15 at 12:36
  • \$\begingroup\$ This solution worked - I excluded the following lines: ` <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter>` And that solved the problem \$\endgroup\$ – NDraskovic Mar 15 '15 at 13:27
0
\$\begingroup\$

This solution worked - I excluded the following lines: <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> And that solved the problem.

\$\endgroup\$
  • 1
    \$\begingroup\$ To clarify, did you delete additional copies of those lines that were added, or did you delete any MAIN/LAUNCHER intents from your manifest? Because I'm not Android expert but I thought you need to have one and only one MAIN/LAUNCHER intent. \$\endgroup\$ – jhocking Mar 15 '15 at 14:48
  • \$\begingroup\$ There was only one instance. When you build the game, Unity creates 2 manifest files - AndroidManifest.xml and AndroidManifest-main.xml. The AndroidManifest.xml holds any data you added in the project (and if you try to search the project in Unity editor, this is the only one you will see), and the main one holds the data that is mandatory and can't/should not be changed. I can confirm that the AndroidManifest-main.xml contains the Main/Launcher intent. Since these two manifests are merged in the apk, I assume that caused the manifest inside the apk to have 2 instances of MAIN/LAUNCHER. \$\endgroup\$ – NDraskovic Mar 15 '15 at 20:48
  • \$\begingroup\$ That would also explain the error that I was getting (incompatible merging). This is just my assumption, I can't claim that it is 100% correct, but I think my logic is valid. \$\endgroup\$ – NDraskovic Mar 15 '15 at 20:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.