apache / cordova-common

Apache Cordova Common Tooling Library
https://cordova.apache.org/
Apache License 2.0
39 stars 40 forks source link

xmlns:tools in edit-config is not working #215

Closed jasonz1987 closed 2 months ago

jasonz1987 commented 2 months ago

Bug Report

Problem

in my plugin.xml


    <edit-config file="AndroidManifest.xml" mode="merge" target="/manifest">
            <manifest xmlns:tools="http://schemas.android.com/tools" />
        </edit-config>

but after install plugin in the capacitor project and run npx cap sync

the AndroidManifest.xml is wrong

<?xml version='1.0' encoding='utf-8'?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:amazon="http://schemas.amazon.com/apk/res/android">
<manifest xmlns:tools="http://schemas.android.com/tools"/>
</manifest>

What is expected to happen?

<?xml version='1.0' encoding='utf-8'?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
xmlns:amazon="http://schemas.amazon.com/apk/res/android">

</manifest>

What does actually happen?

Information

Command or Code

Environment, Platform, Device

Version information

cordova -v 12.0.0 (cordova-lib@12.0.1)

@capacitor/cli: 6.1.2 @capacitor/core: 6.1.2 @capacitor/android: 6.1.2 @capacitor/ios: 6.1.2

Checklist

breautek commented 2 months ago

Tested using the Cordova CLI where:

<edit-config file="AndroidManifest.xml" mode="merge" target="/manifest">
    <manifest xmlns:tools="http://schemas.android.com/tools" />
</edit-config>

is used both from a plugin's plugin.xml and the app's config.xml

In both cases they produced the expected result:

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="10000" android:versionName="1.0.0" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
    <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|smallestScreenSize|screenLayout|uiMode" android:exported="true" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@style/Theme.App.SplashScreen" 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}.cdv.core.file.provider" android:exported="false" android:grantUriPermissions="true" android:name="androidx.core.content.FileProvider">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/cdv_core_file_provider_paths" />
        </provider>
    </application>
    <queries>
        <intent>
            <action android:name="android.media.action.IMAGE_CAPTURE" />
        </intent>
    </queries>
</manifest>

This suggest that the Cordova API is working as intended and your issue might be a CapacitorJS issue. I'm not overly knowledgeable on the Capacitor framework but I was under the impression that they did not support the edit-config directive. I believe they treat the native projects as project files rather than build artefacts, which means the developer can safely make modifications directly to the native projects without the risk of the tooling overriding or conflicting with your modifications. I suggest consulting their documentation and/or support channels to see the best path forward.

I'm closing this issue because there doesn't seem to be anything actionable by Apache Cordova.