You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Ibrahim M. Ghazal (JIRA)" <ji...@apache.org> on 2017/10/31 10:41:00 UTC

[jira] [Created] (CB-13514) in config.xml removes some XML elements added by plugins

Ibrahim M. Ghazal created CB-13514:
--------------------------------------

             Summary: <edit-config> in config.xml removes some XML elements added by plugins
                 Key: CB-13514
                 URL: https://issues.apache.org/jira/browse/CB-13514
             Project: Apache Cordova
          Issue Type: Bug
          Components: cordova-common
    Affects Versions: 2.1.0
         Environment: cordova-android 6.3.0
            Reporter: Ibrahim M. Ghazal


Adding {{<edit-config>}} to config.xml is removing some XML elements added by plugins. For example, {{cordova-plugin-file-opener2}} adds a {{<provider>}} element to AndroidManifest.xml. If I add an {{<edit-config>}} to config.xml that modifies AndroidManifest.xml, the {{<provider>}} element is removed on {{cordova (prepare|build|run) android}}

To reproduce, create a cordova project with the following two files:

package.json
{code}
{
  "name": "com.example.test",
  "displayName": "Test",
  "version": "1.0.0",
  "dependencies": {
    "cordova-android": "6.3.0",
    "cordova-plugin-file-opener2": "2.0.19"
  },
  "cordova": {
    "platforms": [
      "android"
    ],
    "plugins": {
      "cordova-plugin-file-opener2": {}
    }
  }
}
{code}

config.xml
{code}
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.example.test" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>Test</name>
    <content src="index.html" />
    <platform name="android">
        <edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
            <application android:allowBackup="false" />
        </edit-config>
    </platform>
    <engine name="android" spec="6.3.0" />
    <plugin name="cordova-plugin-file-opener2" spec="2.0.19" />
</widget>

{code}

Then run:

$ npm install && cordova platform add android@6.3.0 --nosave
[output omitted]
$ cat .\platforms\android\AndroidManifest.xml
{code}
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="10000" android:versionName="1.0.0" package="com.example.test" xmlns:android="http://schemas.android.com/apk/res/android">
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
    <uses-permission android:name="android.permission.INTERNET" />
    <application android:allowBackup="false" android:hardwareAccelerated="true" android:icon="@mipmap/icon" android:label="@string/app_name" android:supportsRtl="true">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
            <intent-filter android:label="@string/launcher_name">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <provider android:authorities="${applicationId}.opener.provider" android:exported="false" android:grantUriPermissions="true" android:name="io.github.pwlin.cordova.plugins.fileopener2.FileProvider">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/opener_paths" />
        </provider>
    </application>
    <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
</manifest>
{code}
$ cordova run android
Conflict found, edit-config changes from config.xml will overwrite plugin.xml changes
[rest of output omitted]
$ cat .\platforms\android\AndroidManifest.xml
{code}
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="10000" android:versionName="1.0.0" package="com.example.test" xmlns:android="http://schemas.android.com/apk/res/android">
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
    <uses-permission android:name="android.permission.INTERNET" />
    <application android:allowBackup="false" android:hardwareAccelerated="true" android:icon="@mipmap/icon" android:label="@string/app_name" android:supportsRtl="true">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
            <intent-filter android:label="@string/launcher_name">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
    <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
</manifest>
{code}

Note the missing {{<provider>}} element after running {{cordova run android}}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

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