dpa99c / cordova-custom-config

Cordova/Phonegap plugin to update platform configuration files based on preferences and config-file data defined in config.xml
318 stars 84 forks source link

Config.xml Bug #177

Closed javico-dev11 closed 1 year ago

javico-dev11 commented 2 years ago

I am adding android:exported in AndroidManifest.xml but the edited service or activity is duplicated

`

    </activity>

`

For example if I add android:exported it duplicates that code without the added attribute

sarathi0333 commented 1 year ago

@javico-dev11 Have you found a solution? i'm trying to create Android12 support for our app. I too face the same issue when I add android:exported

When we execute "Cordova platform add android" it adds the config, then if we execute Cordova prepare android it creates duplicate.

sarathi0333 commented 1 year ago

I just added the below line in Config.xml and it worked for me. <preference name="cordova-custom-config-autorestore" value="true" />

rondog commented 1 year ago

@sarathi0333 what did your line look like in the config.xml for adding that android:exported value? I am trying to do the same thing, however, its adding the line to the tag.

Currently using this but its wrong

<custom-preference name="android-manifest/application/service[@android:name='org.apache.cordova.firebase.FirebasePluginMessagingService']" value="@android:exported/false" />

rondog commented 1 year ago

I ended up doing this. I think that is what I wanted. I was confused by the docs

        <custom-config-file target="AndroidManifest.xml" parent="./application">
          <service android:name="org.apache.cordova.firebase.FirebasePluginMessagingService" android:exported="false">
            <intent-filter>
              <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
          </service>
        </custom-config-file>
rondog commented 1 year ago

apparently when I run build through the ionic dashboard, this does not work.

tohhierallie commented 1 year ago

Hey Guys,

So this worked for me. I found that the following runs after the firebase plugin edits the manifest. Which means we can delete and add a new service or merge which ever works for you.

<custom-preference delete="true" name="android-manifest/application/service[@android:name='org.apache.cordova.firebase.FirebasePluginMessagingService']" /> 

<custom-config-file mode="merge" parent="./" target="AndroidManifest.xml"> 
    <service android:enabled="true" android:exported="false" android:name="org.apache.cordova.firebase.FirebasePluginMessagingService"> 
        <intent-filter> 
            <action android:name="com.google.firebase.MESSAGING_EVENT" /> 
        </intent-filter> 
    </service> 
</custom-config-file>