“错误:不允许字符串类型(在 'configChanges' 中,值为 'keyboard|keyboardHidden| orien"...在 AndroidManifest.xml 中 [英] "Error: String types not allowed (at 'configChanges' with value 'keyboard|keyboardHidden| orien"... in AndroidManifest.xml

查看:29
本文介绍了“错误:不允许字符串类型(在 'configChanges' 中,值为 'keyboard|keyboardHidden| orien"...在 AndroidManifest.xml 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我是 Android 新手,我使用的是 API 10 (Gingerbread).

Before all, i am a rookie in Android, and i am using API 10 (Gingerbread).

我正在用 libgdx 开发一个简单的游戏.但我只是安装了一切开始工作......在 AndroidManifest.xml 这一行:

I am developing a simple game with libgdx. But i just install everything for start to work and... in the AndroidManifest.xml this line:

android:configChanges="keyboard|keyboardHidden|orientation|screenSize"

控制台出现下一个错误:_

Got the next error in console:_

error: Error: String types not allowed (at 'configChanges' with value 'keyboard|keyboardHidden|orientation|screenSize').

我在 Stackoverflow 中找到了 这个 回答,我改成了 API 13 并且工作了……但我认为应该有一个更好的解决方案,而不是因为一行代码而使应用程序不那么兼容(有很多人仍在使用 Gingerbread).还有其他方法可以解决这个问题吗?

I have found in Stackoverflow this answer, i changed to API 13 and works... but i think there should be a better solution than don't make the app less compatible because one line of code (there is much people that still using Gingerbread). There is another way to fix this?

推荐答案

像这样配置你的 libgdx Android Manifest 并指定 both 最小和目标 sdk 版本:

Configure your libgdx Android Manifest like this and specify both min and target sdk version:

<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="19" />

您可以使用 API 5 作为最低 android 版本,因为这是 libgdx 仍然支持的版本.不要对目标 sdk 版本的含义感到困惑:这基本上意味着您已经针对最新的 android 版本对其进行了测试,这并不意味着它不会在以前的版本上运行,因为您之前已经指定了一个 min sdk.经验法则:min-sdk 尽可能低,target-sdk 尽可能高.

You can use API 5 as the minimum android version as this is what libgdx still supports. Don't get confused about the meaning of the target sdk version: this basically means that you have tested it against latest android version, it doesn't mean that it won't run on previous versions, because you have specified a min sdk before. Rule of thumb: put min-sdk as low as possible and target-sdk as high as possible.

以这种方式配置您的游戏应该仍然可以在旧设备上运行,并且像这样使用 configChanges 也可以:

Configuring it that way your game should still run in old devices and using configChanges like this will work as well:

 android:configChanges="keyboard|keyboardHidden|orientation|screenSize"

我最近刚刚推出了一款具有这样配置的游戏,即使在 Gingerbread 上也能很好地工作;-)

I have just recently launched a game with configurations like this and works like a charm even on Gingerbread ;-)

这篇关于“错误:不允许字符串类型(在 'configChanges' 中,值为 'keyboard|keyboardHidden| orien"...在 AndroidManifest.xml 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆