Preference vanishes from config.xml file

I am trying to set the preference KeyboardResize to false in the config.xml file.

<preference name="KeyboardResize" value="false" />

But i am facing an weird problem. When i give below command to test in my device, the preference vanishes.

ionic cordova run android -c

And UI resize does not stop when keyboard appears.

How to stop vanishing preference? Any idea?

What does that mean? Does it reset your config.xml?

Yes… It resets my config.xml

Does the same happen when you run just cordova run android?

I have the same issue with capacitor.

npx cap sync will reset the config.xml in the android folder.

Where do we set these preferences in the Ionic project?

1 Like

2019 and still the same question

npx cap sync will reset the config.xml in the android folder.

Where do we set these preferences in the Ionic project?

For Capacitor:
https://capacitor.ionicframework.com/docs/apis/keyboard

wekas is this a joke? How a keyboard plugin can help with a
cli/configuration issue? If you are trying to promote something, this
is not the place to do that.

By offering a setResizeMode function that would seem to allow you to do what you are trying to do in a cross-platform manner that avoids the problem you seem to be having entirely.

1 Like

Thanks for the response, but I’m trying to set something different.

<preference name="APP_SECRET" value="1234567890234" />

But everytime “ionic cap sync android” is run that preference is gone
from config.xml

How to solve that?

Sorry, I confused you with OP. Is there a particular reason this specific setting has to be only present in the Android app, and not defined in a cross-platform way?

No joke, I saw you were using Capacitor and sent you a link to relevant documentation.
I assumed it was about keyboard resize as that is what the OP was asking about.
Maybe I could have added more detail but I was quite busy and just trying to get you an quick answer.

Ok, you have my attention. Probably config.xml is not the right
place to set that preference, so, where can we set it?

I guess that depends on:

  • what it is used for (specifically, how many different places in the app need it)
  • in what circumstances it is changed (does it depend on platform? development/staging/production?)

Sorry for my response. I’ve realized you were trying to help. My issue is some how related to OP but is not exactly the same issue.

It depends on the platform, that is why I’m taking android as example. Right now I’ve hardcoded the value in the files android/app/src/main/java/com/my/app/MainActivity.java and ios/App/App/AppDelegate.swift but I would like a better place for it. Or there is no better place?

I’m still not quite sure where in the code needs access to the info, but reading between the lines it seems to be not needed in the JavaScript world, so anything at the Angular level wouldn’t seem to make much sense.

For Android, I guess I would put it as a resource in strings.xml as described here, and for iOS, put it in Info.plist as described here.

I’ll give it a try, but, it would be great if ionic cap sync android updates config.xml instead of fully ovewriting it.