"错误:字符串类型不允许(在'configChanges“,值为”键盘| keyboardHidden |广州澳凌" ...在AndroidManifest.xml不允许、

2023-09-07 17:05:33 作者:向大海哭诉痛

一切之前,我在Android的新人,和我使用API​​ 10(姜饼)。

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

我发展与libgdx一个简单的游戏。但我只是安装家居开始工作,...在的Andr​​oidManifest.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').

我在#1 this答案,我改成13 API和作品...但我认为应该有一个更好的解决方案比不使应用程序少兼容,因为code的一条线(也就是仍然采用姜饼多人)。还有另一种方式来解决这个问题?

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清单如下,并指定两个分和目标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版本的含义:这基本上意味着你已经测试了它针对最新的Andr​​oid版本,这并不意味着它不会在previous版本上运行,因为你已经指定了分SDK之前。经验法则:把分钟-SDK尽可能低和目标-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"

我最近刚刚推出了一个游戏像这样的配置,就像甚至姜饼魅力; - )

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