cordova-common icon indicating copy to clipboard operation
cordova-common copied to clipboard

config-file conflicts between plugins and config.xml

Open QuentinFarizon opened this issue 5 years ago • 0 comments

Bug Report

Problem

I am using https://github.com/QuentinFarizon/cordova-plugin-ble-central/tree/dfu in which plugin.xml adds two tags inside AndroidManufest application tag : https://github.com/QuentinFarizon/cordova-plugin-ble-central/blob/dfu/plugin.xml#L76-L79

I am also using https://github.com/dpa99c/cordova-plugin-firebasex that documents (https://github.com/dpa99c/cordova-plugin-firebasex/#android-default-notification-icon) adding this to my config.xml :

<platform name="android">
    <config-file target="AndroidManifest.xml" parent="/manifest/application">
        <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon" />
    </config-file>
</platform>

What is expected to happen?

No conflict should occur, it should result in :

<application (....)>
   <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon" />
    <activity android:name="com.megster.cordova.ble.central.NotificationActivity" />
    <service android:name="com.megster.cordova.ble.central.DfuService" />
    (...)
</application>

What does actually happen?

During platform/plugin add, everythings goes fine.

Juste before build, AndroidManifest is correct (all lines are present).

During build, this message : "Conflict found, edit-config changes from config.xml will overwrite plugin.xml changes" (I do not have an edit-config in my config.xml).

Issue : activity and service tags from com.megster.cordova.ble.central are NOT added to AndroidManifest (they have been removed).

While debugging inside cordova-common, I can see here the details of conflict :

{
   "conflictFound":true,
   "conflictingMunge":{
      "files":{
         "AndroidManifest.xml":{
            "parents":{
               "/manifest/application":[
                  {
                     "xml":"<activity android:name=\"com.megster.cordova.ble.central.NotificationActivity\" />",
                     "count":1
                  },
                  {
                     "xml":"<service android:name=\"com.megster.cordova.ble.central.DfuService\" />",
                     "count":1
                  },
                  {
                     "xml":"<meta-data android:name=\"com.google.firebase.messaging.default_notification_icon\" android:resource=\"@drawable/notification_icon\" />",
                     "count":0,
                     "id":"config.xml"
                  }
               ]
            }
         }
      }
   },
   "configxmlMunge":{
      "files":{
         
      }
   },
   "conflictWithConfigxml":false,
   "noChanges":[
      
   ],
   "unusedConfigMunge":{
      "files":{
         "AndroidManifest.xml":{
            "parents":{
               "/manifest/application":[
                  {
                     "xml":"<meta-data android:name=\"com.google.firebase.messaging.default_notification_icon\" android:resource=\"@drawable/notification_icon\" />",
                     "count":1,
                     "id":"config.xml"
                  }
               ]
            }
         }
      }
   }
}

Information

Apart from the conflict issue, I think the build should definitely fail if some configurations lines from plugins are removed without more than a warning console line.

Command or Code

cordova build

Environment, Platform, Device

Reproduced on ubuntu and macOS

Version information

cordova 9.0.0 cordova-android 9.0.0 (tested with cordova 10 also, no luck)

Checklist

  • [x] I searched for existing GitHub issues
  • [x] I updated all Cordova tooling to most recent version
  • [x] I included all the necessary information above

QuentinFarizon avatar Dec 31 '20 12:12 QuentinFarizon