cordova-plugin-settings-hook icon indicating copy to clipboard operation
cordova-plugin-settings-hook copied to clipboard

Replace an element defined within the config-file

Open saijanu opened this issue 7 years ago • 3 comments

Hi, If I want to replace an element defined within the config-file how can I do that. Below one is not working for android. It's get appended to the same element <config-file target="AndroidManifest.xml" parent="application"> <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/fb_app_id"/> </config-file>

saijanu avatar Apr 28 '17 06:04 saijanu

Hi, can you provide me a simple cordova project that produce this issue ? I'm not able to reproduce it. Thanks!

mircoc avatar Apr 28 '17 08:04 mircoc

@mircoc I'm running into the same issue. I'm trying to add an activity-alias to my AndroidManifest.xml file and the parent it set to "/manifest/application" but when I try to build the project, I get an error in my output stating

Processing settings for platform: android
{ [Error: Cannot use absolute path on element] token: null, message: 'Cannot use absolute path on element' }

It looks like it still might add the entry, but I'm not sure why the error is being thrown. Here's the logic in my config.xml file.

<platform name="android">
      <resource-file src="res/cs_icon/fc_icon_3322.png" target="app/src/main/res/drawable/fc_icon_3322.png" />
            
      <config-file target="AndroidManifest.xml" parent="/manifest/application">
            <activity-alias android:configChanges="orientation|screenSize" android:noHistory="true" android:name=".MainActivity_3322" android:enabled="false" android:icon="@drawable/fc_icon_3322" android:label="@string/app_name" android:targetActivity=".MainActivity">
                    <intent-filter>
                        <action android:name="android.intent.action.MAIN" />
                        <category android:name="android.intent.category.LAUNCHER" />
                    </intent-filter>
                </activity-alias>

                <!-- possibly needs to be the last entry??? -->
                <activity-alias android:enabled="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:name=".MainActivity_default" android:targetActivity=".MainActivity">
                    <intent-filter>
                        <action android:name="android.intent.action.MAIN"/>
                        <category android:name="android.intent.category.LAUNCHER"/>
                    </intent-filter>
                    <intent-filter>
                        <action android:name="android.intent.action.VIEW"/>
                        <category android:name="android.intent.category.DEFAULT"/>
                        <category android:name="android.intent.category.BROWSABLE"/>
                        <data android:host="www.faithconnector.com" android:scheme="http"/>
                    </intent-filter>
                </activity-alias>
            </config-file>           
        </platform>

If I change the config-file parent to "manifest/application", it doesn't insert into the proper location. It looks like it needs to have the slash in front of it. Thanks Adam

kd8ssq avatar Jun 10 '19 15:06 kd8ssq

I might have found a workaround, at least for my case in need to manipulate the application tags inside the AndroidManifest.xml. In looking at the updatePlatformConfig.js code for the plugin, I noticed when preferenceMappingData is defined (around line 98) that there's an entry to change the application name and the parent is set to "application" instead of "/manifest/application". When I changed my code to just have the parent of "application" it works.

I think this is a workaround and still should support the other format of "/manifest/application" though.

kd8ssq avatar Jun 10 '19 15:06 kd8ssq