Closed durvilchat closed 6 years ago
You can use this plugin to insert configuration for another activity into your <application>
like this:
<custom-config-file target="AndroidManifest.xml" parent="./application">
<activity android:name="MainActivity2" android:foo="bar" >
<!-- your activity config -->
</activity>
</custom-config-file>
So you take the configuration you created in AndroidManifest.xml
using Android Studio and use the above as a template.
However, you will still need to write the Java code to implement the activity. This plugin will not help you with that.
Closed due to no response from OP
Hello, I'm trying to add an activity to the manifest as well but when i try:
<custom-config-file target="AndroidManifest.xml" parent="/application">
I'm getting this error:
Error: Unable to graft xml at selector "/application" from "/platforms/android/AndroidManifest.xml" during config install
And when i check the manifest file it has the activity i wanted to add but outside the application tag.
@valerymadiedo Apologies there was a typo in my example above: it should be parent="./application"
- not parent="/application"
i.e. is should start with .
@dpa99c Thank you for your quick response. Also I tried with ./
in this code inside the android platform tag:
<custom-config-file mode="add" parent="./manifest/application" target="AndroidManifest.xml">
<activity android:launchMode="singleInstance" android:name="NewActivity" />
</custom-config-file>
But now i get this error:
error: Error parsing XML: unbound prefix
* What went wrong:
Execution failed for task ':processDebugResources'.
com.android.ide.common.process.ProcessException: Failed to execute aapt
@valerymadiedo you added manifest
into the XPath which is incorrect; it should be:
<custom-config-file mode="add" parent="./application" target="AndroidManifest.xml">
<activity android:launchMode="singleInstance" android:name="NewActivity" />
</custom-config-file>
See the documentation for example usage.
Thank you, now it works.
@valerymadiedo Check your config.xml
for unclosed tags or attributes. You can validate the XML here: https://www.xmlvalidation.com/
In my case the xmlns:android="http://schemas.android.com/apk/res/android"
was missing from the widget tag. Thank you a lot for your help.
Hello my friends please i really need your help, i would like to create an app that has two launch icons (two mainActivities this is fine on android studio) and i have a serious problem as cordova does not generates only one MainActivity. If you would like to know how to do it Thank you.