In **AndroidManifest.xml** I have an **Activity** in portrait mode:
<activity
android:name=".home.MainActivity"
android:screenOrientation="portrait">
I found it useful to temporary remove android:screenOrientation="portrait" line during development in order to earlier catch bugs related to saving instance state.
Is it possible to set screen orientation to portrait in the release build only and for the debug build keep the default behaviour?
It can be achieved by mentioning configuration for release in build.gradle file of app using manifestPlaceholder property as shown below. And remove it from manifest file. Also for debug build you can specify separately as well.
android {
...
buildTypes {
release {
...
manifestPlaceholders.screenOrientation = "portrait"
}
debug {...}
}
}
To understand more on manifestPlaceholders and build favour kindly refer here and at official site
You can override parts of your AndroidManifest in debug build. In src/debug create another AndroidManifest.xml, and tell the merge tool to replace the screenOrientation attribute for your activity:
<activity
android:name=".home.MainActivity"
tools:replace="android:screenOrientation"
android:screenOrientation="unspecified"/>
See docs for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With