You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2019/08/13 06:47:26 UTC

[GitHub] [cordova-android] dpa99c opened a new issue #809: blocks in config.xml overwrites those in plugin.xml

dpa99c opened a new issue #809: <config-file> blocks in config.xml overwrites those in plugin.xml
URL: https://github.com/apache/cordova-android/issues/809
 
 
   
   
   # Bug Report
   
   ## Problem
   `<config-file target="AndroidManifest.xml">` blocks in `config.xml` seems to overwrite similar blocks added via the `plugin.xml` of plugins.
   This seems to be a regression bug in `cordova@9` / `cordova-lib@9)` since the same issue does not occur using `cordova@8` / `cordova-lib@8)`.
   
   
   ### What is expected to happen?
   On adding the Android platform, the contents of `<config-file>` blocks from both `config.xml` and `plugin.xml` appear in `AndroidManifest.xml`.
   
   
   ### What does actually happen?
   On adding the Android platform, only the contents of `<config-file>` blocks from both `config.xml` appear in `AndroidManifest.xml`. Those from `plugin.xml` are missing.
   
   
   ## Information
   <!-- Include all relevant information that might help understand and reproduce the problem -->
   I've created a [test project](http://ge.tt/3FYiuXx2) to illustrate the issue.
   
   It contains a dummy plugin with the following `<config-file>` blocks in its `plugin.xml`:
   
       <config-file target="AndroidManifest.xml" parent="/*">
         <meta-data android:name="manifest_block" android:value="from_plugin_xml" />
       </config-file>
   
       <config-file target="AndroidManifest.xml" parent="application">
         <meta-data android:name="application_block" android:value="from_plugin_xml" />
       </config-file>
   
   And the following blocks in `config.xml`:
   
       <config-file target="AndroidManifest.xml" parent="/*">
           <meta-data android:name="manifest_block" android:value="from_config_xml" />
       </config-file>
       <config-file target="AndroidManifest.xml" parent="application">
           <meta-data android:name="application_block" android:value="from_config_xml" />
       </config-file>
   
   
   On running `cordova platform add android@8.0.0` with `cordova@9.0.0 (cordova-lib@9.0.1)`, the resulting `AndroidManifest.xml` is:
   
       <manifest android:hardwareAccelerated="true" android:versionCode="10000" android:versionName="1.0.0" package="io.cordova.hellocordova" 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:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" 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>
               <meta-data android:name="application_block" android:value="from_config_xml" />
           </application>
           <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="28" />
           <meta-data android:name="manifest_block" android:value="from_config_xml" />
       </manifest>
   
   As can be seen, it contains the entries for `config.xml` but not from the plugin's `plugin.xml`.
   
   
   On running `cordova platform add android@8.0.0` with `8.1.2 (cordova-lib@8.1.1)`, the resulting `AndroidManifest.xml` is:
   
       <?xml version='1.0' encoding='utf-8'?>
       <manifest android:hardwareAccelerated="true" android:versionCode="10000" android:versionName="1.0.0" package="io.cordova.hellocordova" 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:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" 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>
               <meta-data android:name="application_block" android:value="from_config_xml" />
               <meta-data android:name="application_block" android:value="from_plugin_xml" />
           </application>
           <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="28" />
           <meta-data android:name="manifest_block" android:value="from_config_xml" />
           <meta-data android:name="manifest_block" android:value="from_plugin_xml" />
       </manifest>
   
   i.e. the entries from `plugin.xml` are not missing and the result is as expected.
   
   If I remove the `<config-file>` blocks from `config.xml` and run `cordova platform add android@8.0.0` with `cordova@9.0.0 (cordova-lib@9.0.1)`, the resulting `AndroidManifest.xml` is:
   
       <?xml version='1.0' encoding='utf-8'?>
       <manifest android:hardwareAccelerated="true" android:versionCode="10000" android:versionName="1.0.0" package="io.cordova.hellocordova" 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:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" 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>
               <meta-data android:name="application_block" android:value="from_plugin_xml" />
           </application>
           <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="28" />
           <meta-data android:name="manifest_block" android:value="from_plugin_xml" />
       </manifest>
   
   Now the `<config-file>` blocks from `plugin.xml` are present, indicated a conflict with those in `config.xml` is causing the issue.
   
   
   
   For now I have worked around this issue by installing [cordova-custom-config](https://github.com/dpa99c/cordova-custom-config) in my projects and using `<custom-config-file>` blocks in the `config.xml`.
   
   
   ### Command or Code
   <!-- What command or code is needed to reproduce the problem? -->
   To reproduce the issue:
   - Download and unzip the [test project](http://ge.tt/3FYiuXx2)
   - Using `cordova@9` / `cordova-lib@9)`, run `cordova platform add android@8.0.0`
   - Observe that `platforms/android/app/src/main/AndroidManifest.xml` doesn't contain the contents of `<config-file>` blocks from the `plugin.xml`
   
   
   
   ### Environment, Platform, Device
   <!-- In what environment, on what platform or on which device are you experiencing the issue? -->
   Android platform
   
   
   ### 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.
   -->
   $ cordova -v
   9.0.0 (cordova-lib@9.0.1)
   
   $ node -v
   v10.15.3
   
   $ nvm version
   1.1.6
   
   OS: Windows 10 1809
   
   ## Checklist
   <!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
   
   - [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
   

----------------------------------------------------------------
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


With regards,
Apache Git Services

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