- Home /
How to merge multiple AndroidManifest.xml files??
Hello!, i need help i have been stuck for about a week with this, i used multiple plugins on a proyect and those plugins uses the AndroidManifest.xml, so when i import a plugin it overwrites the old AndroidManifest, so i have picked all of them individually and im looking a way to merge them all.
The plugins im using are:
Google Play OBB Downloader
Everyplay
Mobile Social Plugin
GameAnalytics Unity Package
Qualcomm Vuforia
Yeah i know thats a lot of plugins, i have tried merging the files manually but i dont really know how it works so the new merged AndroidManifest didnt work, i have been investigating and i think it has to do with the < intent-filter >, from what i have read it should be only one < activity > with the < intent-filter > on the entire < application >.
Im not even sure that if merging those files the way i did its the right way to do it, i need someone to point me in the right direction.
Im uploading here all the manifests and the one i created merging all those, if you need more information or another file just tell me and i will upload it or give the information needed, Thank You! :)
Ever figure this out? I'm trying to merge Unibill and Everyplay plugins but I haven't a clue where to start.
I managed to connect Facebook and Vuforia i am going to post my answer later today! :)
Answer by Lucas_Gaspar · Aug 08, 2014 at 09:00 PM
Hello, i managed to merge two plugins who used the actions "android.intent.action.MAIN" and "android.intent.category.LAUNCHER" (that is the main conflict, you can have any number of activities but just only one with those two actions) so here is what i did.
The plugins i merged where Mobile Social Plugin and the Vuforia plugin.
I mailed the developer of the Mobile Social Plugin (wich i recommend) asking for advice, he told me that i should recompile the .jar file but include all other plugins there. In the same package of the plguin there is a .zip called "ANEclipseProject.zip" where the entire Eclipse proyect was located.
I needed Eclipse so i downloaded Eclipse for Android from here AndroidSDK+Eclipse i created a new Eclipse proyect and added the files i got from the zip, then i added the .jar files of the Vuforia plugin ("QCARUnityPlayer.jar" and "Vuforia.jar" to be exact).
Now you have to find how its called the main script, to do this i looked in the manifest how it was called the Activity that wanted the actions MAIN and LAUNCHER, in the Mobile Social Plugin its called "AndroidNativeBridge" find that file in the proyect and open it.
Now you have to find how its named the other plugin activity that wants the actions MAIN and LAUNCHER, for example for vuforia its named "QCARPlayerNativeActivity", what you should do now is extend the file you opened before (AndroidNativeBridge) to the class "QCARPlayerNativeActivity" (before this the file should be extending "UnityPlayerActivity"), dont forget to add the "import com.qualcomm.QCARUnityPlayer.QCARPlayerNativeActivity;" to the import list to be detected correctly. (the complete name can be seen on the manifest)
Then Eclipse automatically recompiles itself, you can find the .jar in the folder "bin" inside the Eclipse proyect with the name "androidnative.jar" and this file its what you need to overwrite in your proyect, find the file inside unity and replace it with your new .jar.
Now all you need to do is adjust the manifest to include all the activities and permissions of both of the plugins, and in the secondary plugin activities delete the lines where tries to use the actions MAIN and LAUNCHER.
So basically what you need is the Eclipse proyect of one of the plugins and include the jar files of the other plugins, extend the main activity to them and adjust the manifest to include all the atcivities.
Here is the links that was given to me where i got the information about merging the two plugins. https://docs.google.com/document/d/1px0BVXcZqgrW99OQV4bM7q1rD5NYaCYTxXnn4eS4ytY/edit#heading=h.7frodoz468gu https://docs.google.com/document/d/1px0BVXcZqgrW99OQV4bM7q1rD5NYaCYTxXnn4eS4ytY/edit#heading=h.284j90a89lo8 https://docs.google.com/document/d/1px0BVXcZqgrW99OQV4bM7q1rD5NYaCYTxXnn4eS4ytY/edit#heading=h.66wnkolqt5dq
I hope this helps, you can ask me if you have any question, im not an expert but i will try to help. :)
I used Android native plugin package for unity too. Your solution is very nice, but I still have some questions.
You mean put the second plugin in Android native project right? Its mean copy the package of second plugin in Android native project, and set the Active turn to extend AndroidNativeBridge?
If I built a plugin by my self, I have 3~4 class in one package, So if I fix code at Active class like this:
public class myPlugin extends Active -->
public class myPlugin extends AndroidNativeBridge. And copy the whole package in the AndroidNative project, Is it correct?
By the way, How can I import other .jar in the peoject(eclipse), Because I can't find out the .jar in the file when I imported. Im sure the .jar is in the file.
I used AndroidNativePlugin for unity too, Your solution is very nice, but I still have some question.
You mean copy the second plugin's .jar in the AndroidNative project and change extend Active to extend AndroidNativeBridge, right?
If I built a plugin in eclipse, that have 3~4 class in a package.SO, I just copy the whole package in AndroidNative project, and fix the Active class like this:
public class myPlugin extend Active ---> public class myPlugin extend AndroidNativeBridge,right? Is that correct? Because I'm not familiar in eclipse, so I can't sure what I did is correct or not.
By the way, How can I import .jar in the eclipse project. I can't find out the .jar in the folder when I imported. I'm sure that the .jar is in the folder exactly.What is the problem. thank you :)
To add a .jar to eclipse you have to rigth click on the main proyect then "Build Path"/"Configure Build Path" then a window should appear, go to the tab "Libraries" then on the button "Add External JARs". This will make the other .jar part of your proyect so you can reference them on your code. I hope it helps :)
Hi, thank you for your solution. I extend Android native plugin to my other plugin, and I have a new Android native.jar , So I replace it to my Unity Project. And my other plugin.jar also have to put in my Unity Project?
Hello, I've followed each and every step of https://developer.vuforia.com/resources/dev-guide/unity-android-plugins https://developer.vuforia.com/resources/dev-guide/extending-unity-android-activity-and-adding-custom-views-eclipse https://unionassets.com/android-native-plugin/can-i-use-this-plugin-with-other-android-plugins-103 Currently using the "AndroidNativeBridge extends QCARPlayerNativeActivity" pattern, the .jar file seems to recompile correctly, but i cannot get both plugins to work together : the latest builds throws an
AndroidJavaException: java.lang.NoSuch$$anonymous$$ethodError: no method with name='getClass' signature='()Ljava/lang/Object;' in class Lcom/androidnative/AndroidNativeBridge;
I understand getClass is a top-level java method and cannot be overridden, and i'm no Android dev... If anyone got this working, I would be very grateful for pointers, or even an example androidmanifest file :) Thanks
Answer by liortal · Aug 06, 2014 at 05:17 PM
To answer this, i can generally say that there may be scenarios where multiple AndroidManifests.xml will be OK, and there will be times where it won't.
The only rule is that there's no general solution for making it work (if any, at all).
Your claim regarding multiple activities in a single manifest is wrong, as you can see in some of the attached files, where multiple elements are defined.
Unity claims to perform some merging of provided AndroidManifests (e.g: the main one under Plugins/Android will be merged with others that are placed in subfolders of Plugins/Android) - quoted from here: http://docs.unity3d.com/Manual/PluginsForAndroid.html
The issue is that each plugin defines its own Activity that should be the LAUNCHER activity (the "entry point" to the app), and so multiple plugins will not be able to co-exist.
So, for this scenario, there's no easy solution.
I would try to do the following:
Double check to see if i really need that many plugins?
Verify with the plugin developer if there's a version or option to not use the manifest and their activity ?
Following #2, check if there's an option to manually initialize the plugin code, and if so, create my own custom activity that will do the initialization (skipping the need for the plugin to have its own activity).
Answer by unity_s_uRTmg4Kx61_A · Oct 03, 2017 at 10:11 AM
Hello everyone,
This may be coming late, but it can help other people out there to solve the issue of using two or more plugin in your unity android project. Most especially Vuforia and any other plugin. I had spend many days, weeks, and not able to combine the androidmanifest.xml of the two plugins. All of the credits go to this great guy (https://forum.unity.com/members/eppz.665736/). He made a very detailed tutorial on how to use multiple plugin in your project. All you have to do is first read carefully, identify the exact files and edit the exact lines. The link to the tutorial is http://eppz.eu/blog/unity-android-plugin-tutorial-1/ , you can also ask me any question and I can help you as much as I can.
Thanks everyone.
Your answer
Follow this Question
Related Questions
How do I make an Android plugin for unity? 0 Answers
Will an Android Manifest file named "AndroidManifest 1.xml" file work? 1 Answer
FileNotFoundException: Could not find file MyProject\Temp\StagingArea\AndroidManifest.xml 0 Answers
How to check if user has given camera or location permissions (android) 0 Answers
correct approach for using e.g. three android plugins 0 Answers