How do you force a landscape orientation for mobile apps built with cordova-cli?

android, cordova, phonegap-build

Solution

Simply put, it's not possible to set the orientation using a `preference` element in the `www/config.xml`. After inspecting the cordova-cli code it appears that only the version and entry class package are updated in the `AndroidManifest.xml`.

For a list of supported preferences see the Cordova Docs.

Added configurations to the `AndroidManifest.xml` file should not be lost on `cordova build`, unless the config option is pulled from somewhere else (i.e. version).

Problem

I'm using cordova cli to build my app. I want to target both android and ios (maybe more). As I want this to be true for all platforms, I was hoping I could simply define this as a preference in the config.xml like this: ``` <preference name="orientation" value="landscape" /> ``` because this is apparently how it works in the phonegap build https://build.phonegap.com/docs/config-xml I assume the features supported in config.xml by phonegap build are different to those by cordova-cli? I know I can force it in the android app by inserting `android:screenOrientation="landscape"` into my AndroidManifest.xml, but that's no good because it will be over-written the next time I perform a `cordova build`. Any suggestions?

Original source