在 **AndroidManifest.xml**
我有一个纵向模式的 **Activity**
:
<activity
android:name=".home.MainActivity"
android:screenOrientation="portrait">
我发现在开发期间临时删除 android:screenOrientation="portrait"
行很有用,以便更早地捕获与保存实例状态相关的错误。
是否可以仅在 release 版本中将屏幕方向设置为纵向,而对于 debug 版本保持默认行为?
最佳答案
可以通过使用 manifestPlaceholder
属性在应用程序的 build.gradle
文件中提及发布配置来实现,如下所示。并将其从 list 文件中删除。对于调试构建,您也可以单独指定。
android {
...
buildTypes {
release {
...
manifestPlaceholders.screenOrientation = "portrait"
}
debug {...}
}
}
要了解有关 manifestPlaceholders
的更多信息并获得青睐,请参阅 here在 official site
关于android - 仅在发布版本中将 screenOrientation 设置为 "portrait",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59321089/