You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2020/11/15 18:27:04 UTC

[GitHub] [cordova-common] premji012 opened a new issue #154: Problem with edit-config attribute in plugin.xml

premji012 opened a new issue #154:
URL: https://github.com/apache/cordova-common/issues/154


   # Bug Report
   
   ## Problem
   A specific configuration done using edit-config element in plugin.xml, applies properly when plugin is added through cordova plugin add. But the same edit-config results in a bug if cordova prepare command is used whenever after adding the plugin.
   The config that i used is as follows,
   <edit-config file="AndroidManifest.xml" target="/manifest/application/activity[@android:name='MainActivity']" mode="merge">
         <activity android:name="org.apache.cordova.log.MultiViewActivity" />
   </edit-config>
   I tried to use my custom activity in place of MainActivity
   
   ### What is expected to happen?
   <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:label="@string/activity_name"  android:name="MultiViewActivity">
               <intent-filter android:label="@string/launcher_name">
                   <action android:name="android.intent.action.MAIN" />
                   <category android:name="android.intent.category.LAUNCHER" />
               </intent-filter>
           </activity>
   
   
   ### What does actually happen?
   <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:label="@string/activity_name"  android:name="MultiViewActivity">
               <intent-filter android:label="@string/launcher_name">
                   <action android:name="android.intent.action.MAIN" />
                   <category android:name="android.intent.category.LAUNCHER" />
               </intent-filter>
           </activity>
   
   <activity android:name="org.apache.cordova.plugin_name.MultiViewActivity" />
   
   
   ## Information
   <!-- Include all relevant information that might help understand and reproduce the problem -->
   First time when i add plugin, it works fine. The MainActivity name is replaced with MultiViewActivity.
   But after i run cordova prepare, the extra activity tag for same className get appened which causes two activity element with same name error and build fails. Even console error is thrown for cordova prepare command
   
   
   ### Command or Code
   <!-- What command or code is needed to reproduce the problem? -->
   
   
   
   ### Environment, Platform, Device
   <!-- In what environment, on what platform or on which device are you experiencing the issue? -->
   I am using cordova 10.0.0 and cordova-android version 9.0.0
   
   
   ### Version information
   <!--
   What are relevant versions you are using?
   For example:
   Cordova: Cordova CLI, Cordova Platforms, Cordova Plugins
   Other Frameworks: Ionic Framework and CLI version
   Operating System, Android Studio, Xcode etc.
   -->
   
   
   
   ## Checklist
   <!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
   
   - [ ] I searched for existing GitHub issues
   - [ ] I updated all Cordova tooling to most recent version
   - [ ] I included all the necessary information above
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-common] premji012 commented on issue #154: Problem with edit-config attribute in plugin.xml

Posted by GitBox <gi...@apache.org>.
premji012 commented on issue #154:
URL: https://github.com/apache/cordova-common/issues/154#issuecomment-728683759


   > > But if i run cordova prepare in between and then run cordova plugin rm, the android:name value is not reverted it stays the same.
   > 
   > Are you able to provide a [sample reproduction app](https://github.com/apache/cordova-contribute/blob/master/create-reproduction.md) that demonstrates this issue?
   
   As just a barebone app is enough to verify this issue, what i have given is enough i think. Just follow the steps and you will be able to get through it.
   
   Anyways for plugin code, i already created it as a github repo. So here goes - [https://github.com/premji012/TestCordovaPlugin.git](url)


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-common] raphinesse commented on issue #154: Problem with edit-config attribute in plugin.xml

Posted by GitBox <gi...@apache.org>.
raphinesse commented on issue #154:
URL: https://github.com/apache/cordova-common/issues/154#issuecomment-727868298


   I suggest you try asking for help in [our slack](http://slack.cordova.io/). Maybe there's a proper way to do what you want :man_shrugging: 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-common] premji012 commented on issue #154: Problem with edit-config attribute in plugin.xml

Posted by GitBox <gi...@apache.org>.
premji012 commented on issue #154:
URL: https://github.com/apache/cordova-common/issues/154#issuecomment-727877540


   Its working properly now. I think unfortunately i would have used app_name instead activity_name. Thanks for the support


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-common] breautek edited a comment on issue #154: Problem with edit-config attribute in plugin.xml

Posted by GitBox <gi...@apache.org>.
breautek edited a comment on issue #154:
URL: https://github.com/apache/cordova-common/issues/154#issuecomment-728077686


   > But if i run cordova prepare in between and then run cordova plugin rm, the android:name value is not reverted it stays the same.
   
   Are you able to provide a [sample reproduction app](https://github.com/apache/cordova-contribute/blob/master/create-reproduction.md) that demonstrates this issue?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-common] breautek commented on issue #154: Problem with edit-config attribute in plugin.xml

Posted by GitBox <gi...@apache.org>.
breautek commented on issue #154:
URL: https://github.com/apache/cordova-common/issues/154#issuecomment-729679390


   I see, I've observed the behaviour but I'm not sure if this is a bug. Plugins in general are responsible for cleaning up after themselves. So I'll be leaving this issue as closed.
   
   I think the best course of action is for the plugin to implement the `before_plugin_uninstall` hook which reverts it's change to `AndroidManifest.xml`. However, it looks like you can't simply reuse the `<edit-config>` style to do this... since it appears hooks expects a script file and the recommended way is to provide a NodeJS script. I'm not that familiar with the common codebase, but I *assume* it's possible to use the Config merging code from within a hook. I would ask the people on our [Slack](http://slack.cordova.io/) for advice.
   
   https://cordova.apache.org/docs/en/latest/guide/appdev/hooks/index.html


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-common] premji012 commented on issue #154: Problem with edit-config attribute in plugin.xml

Posted by GitBox <gi...@apache.org>.
premji012 commented on issue #154:
URL: https://github.com/apache/cordova-common/issues/154#issuecomment-728682488


   Github link of the plugin repo -[https://github.com/premji012/TestCordovaPlugin.git](url)


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-common] premji012 edited a comment on issue #154: Problem with edit-config attribute in plugin.xml

Posted by GitBox <gi...@apache.org>.
premji012 edited a comment on issue #154:
URL: https://github.com/apache/cordova-common/issues/154#issuecomment-728147031


   Step 1: Just create an app using **cordova create** and add android platform (**cordova platform add android**)
   Step 2: Add the following plugin to the app using command - **cordova plugin add path_to_plugin_folder**
   [TestCordovaPlugin.zip](https://github.com/apache/cordova-common/files/5547320/TestCordovaPlugin.zip)
   
   Step 3: By Now in AndroidManifest.xml, launcher activity className would have be updated by MultiViewActivity. Now run **cordova prepare**
   
   Step 4: Now remove the plugin using command **cordova plugin rm cordova-plugin-log**


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-common] premji012 commented on issue #154: Problem with edit-config attribute in plugin.xml

Posted by GitBox <gi...@apache.org>.
premji012 commented on issue #154:
URL: https://github.com/apache/cordova-common/issues/154#issuecomment-727914144


   > Maybe you could just select the target Activity based on another attribute. `android:label="@string/activity_name"` might be unique to the MainActivity as well...
   
   Even if i use android label to update android:name, it is properly reverted when i remove plugin. But if i run cordova prepare in between and then run cordova plugin rm, the android:name value is not reverted it stays the same.
   
   Order of commands:
   
   1. cordova plugin add "cordova-plugin-example"
   2. cordova prepare
   3. cordova plugin rm "cordova-plugin=example"


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-common] premji012 edited a comment on issue #154: Problem with edit-config attribute in plugin.xml

Posted by GitBox <gi...@apache.org>.
premji012 edited a comment on issue #154:
URL: https://github.com/apache/cordova-common/issues/154#issuecomment-728682488


   @breautek 
   Github link of the plugin repo -[https://github.com/premji012/TestCordovaPlugin.git](url)


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-common] premji012 commented on issue #154: Problem with edit-config attribute in plugin.xml

Posted by GitBox <gi...@apache.org>.
premji012 commented on issue #154:
URL: https://github.com/apache/cordova-common/issues/154#issuecomment-728209493


   Ohh only now i saw the required process for sharing a sample reproduction app. I will do that tomorrow morning. But the above step too works if you just wanna check if its a bug


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-common] premji012 edited a comment on issue #154: Problem with edit-config attribute in plugin.xml

Posted by GitBox <gi...@apache.org>.
premji012 edited a comment on issue #154:
URL: https://github.com/apache/cordova-common/issues/154#issuecomment-728147031


   Step 1: Just create an app using **cordova create** and add android platform (**cordova platform add android**)
   Step 2: Add the following plugin to the app using command - **cordova plugin add path_to_plugin_folder**
   [TestCordovaPlugin.zip](https://github.com/apache/cordova-common/files/5547320/TestCordovaPlugin.zip)
   
   Step 3: By Now in AndroidManifest.xml, launcher activity className would have be updated by **org.apache.cordova.MultiViewActivity**. Now run **cordova prepare**
   
   Step 4: Now remove the plugin using command **cordova plugin rm cordova-plugin-log**


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-common] raphinesse closed issue #154: Problem with edit-config attribute in plugin.xml

Posted by GitBox <gi...@apache.org>.
raphinesse closed issue #154:
URL: https://github.com/apache/cordova-common/issues/154


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-common] raphinesse commented on issue #154: Problem with edit-config attribute in plugin.xml

Posted by GitBox <gi...@apache.org>.
raphinesse commented on issue #154:
URL: https://github.com/apache/cordova-common/issues/154#issuecomment-727870001


   Maybe you could just select the target Activity based on another attribute. `android:label="@string/activity_name"` might be unique to the MainActivity as well...


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-common] premji012 removed a comment on issue #154: Problem with edit-config attribute in plugin.xml

Posted by GitBox <gi...@apache.org>.
premji012 removed a comment on issue #154:
URL: https://github.com/apache/cordova-common/issues/154#issuecomment-728681265






----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-common] breautek commented on issue #154: Problem with edit-config attribute in plugin.xml

Posted by GitBox <gi...@apache.org>.
breautek commented on issue #154:
URL: https://github.com/apache/cordova-common/issues/154#issuecomment-728077686


   > But if i run cordova prepare in between and then run cordova plugin rm, the android:name value is not reverted it stays the same.
   
   Are you able to provide a [sample reproduction app](https://github.com/apache/cordova-contribute/blob/master/deprecation.md) that demonstrates this issue?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-common] raphinesse commented on issue #154: Problem with edit-config attribute in plugin.xml

Posted by GitBox <gi...@apache.org>.
raphinesse commented on issue #154:
URL: https://github.com/apache/cordova-common/issues/154#issuecomment-727841482


   You `edit-config` targets `/manifest/application/activity[@android:name='MainActivity']`. I suppose that on a `prepare` the `edit-config` will be applied to a manifest file that already has changes. Thus, your `XPath` selector won't match the activity tag you want to change.
   
   I suggest you keep your `edit-config`s [idempotent](https://en.wikipedia.org/wiki/Idempotence). Since your provided `edit-config` is changing an attribute that it uses to select its target, it is not idempotent.
   
   I'm closing this for now. If you still feel this is a problem with Cordova, please feel free to respond here.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-common] premji012 commented on issue #154: Problem with edit-config attribute in plugin.xml

Posted by GitBox <gi...@apache.org>.
premji012 commented on issue #154:
URL: https://github.com/apache/cordova-common/issues/154#issuecomment-727863804


   I tried doing this in order to use my custom MainActivity. For selecting a already declared MainActivity i used **/manifest/application/activity[@android:name='MainActivity']** as target. And i used mode=merge to only change the required attribute and leave others.
   
   Initially i thought i could use template for that, but unfortunately templates cannot be used for platform specific files.
   
   So i am looking for a suitable solution. For now as a last resort i thought about using hooks to overwrite the MainActivity when the corresponding plugin which requires a custom MainActivity is installed. And using a hook to revert it when the corresponding plugin is uninstalled.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-common] premji012 edited a comment on issue #154: Problem with edit-config attribute in plugin.xml

Posted by GitBox <gi...@apache.org>.
premji012 edited a comment on issue #154:
URL: https://github.com/apache/cordova-common/issues/154#issuecomment-728147031


   Step 1: Just create an app using **cordova create** and add android platform (**cordova platform add android**)
   Step 2: Add the following plugin to the app using command - **cordova plugin add path_to_plugin_folder**
   [TestCordovaPlugin.zip](https://github.com/apache/cordova-common/files/5547320/TestCordovaPlugin.zip)
   
   Step 3: Now in AndroidManifest.xml, launcher activity className would be updated by MultiViewActivity. Now run **cordova prepare**
   
   Step 4: Now remove the plugin using command **cordova plugin rm cordova-plugin-log**


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-common] premji012 commented on issue #154: Problem with edit-config attribute in plugin.xml

Posted by GitBox <gi...@apache.org>.
premji012 commented on issue #154:
URL: https://github.com/apache/cordova-common/issues/154#issuecomment-728147031


   Step 1: Just create an app using **cordova create**
   Step 2: add plugin using the following directory
   [TestCordovaPlugin.zip](https://github.com/apache/cordova-common/files/5547320/TestCordovaPlugin.zip)
   
   Step 3: Now in AndroidManifest.xml, launcher activity className would be updated by MultiViewActivity. Now run **cordova prepare**
   
   Step 4: Now remove the plugin using command **cordova plugin rm cordova-plugin-log**


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-common] premji012 commented on issue #154: Problem with edit-config attribute in plugin.xml

Posted by GitBox <gi...@apache.org>.
premji012 commented on issue #154:
URL: https://github.com/apache/cordova-common/issues/154#issuecomment-727874077


   Actually i thought about this but i think i might have overlooked it and used "@string/app_name" instead. Anyway thanks for your immediate response. I will get back to you after checking if this works


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-common] premji012 commented on issue #154: Problem with edit-config attribute in plugin.xml

Posted by GitBox <gi...@apache.org>.
premji012 commented on issue #154:
URL: https://github.com/apache/cordova-common/issues/154#issuecomment-728681265


   As just a barebone app is enough to verify this issue, what i have given is enough i think. Just follow the steps and you will be able to get through it


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org