Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace an element defined within the config-file #11

Open
saijanu opened this issue Apr 28, 2017 · 3 comments
Open

Replace an element defined within the config-file #11

saijanu opened this issue Apr 28, 2017 · 3 comments
Assignees

Comments

@saijanu
Copy link

saijanu commented Apr 28, 2017

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>

@mircoc
Copy link
Owner

mircoc commented Apr 28, 2017

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

@mircoc mircoc self-assigned this Apr 28, 2017
@kd8ssq
Copy link

kd8ssq commented Jun 10, 2019

@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
Copy link

kd8ssq commented Jun 10, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants