android:screenOrientation=“sensorLandscape” showing error for a project with the minimum SDK as 2.2

≯℡__Kan透↙ 提交于 2019-12-11 10:06:50

问题


I'm trying to set android:screenOrientation="sensorLandscape" for one of my activities, to enable landscape left and landscape right.

In my project properties, I've set the project build target to Android 2.2. In my manifest, the minimum SDK version is set to Android 2.2 as well (API level 8): The line in my manifest is:

<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="10"/>

According to the docs, the "sensorLandscape" attribute should be available to me, but still, when I try setting it, the error I get is "error: Error: String type not allowed (at "screenOrientation" with value "sensorLandscape")".

Am I missing some extra setting somewhere?


回答1:


"sensorLandscape":Landscape orientation, but can be either normal or reverse landscape based on the device sensor.Added in API level 9. so i think your minsdkVersion should be 9 instead of 8...




回答2:


Aha! This environment is just /made/ to drive you nuts, isn't it?

For my project I was setting the minSDK to 9 or even 12, nothing made any difference.

Of course, when I'd created the project, I'd built it for minSDK 8...which means I had the android-8 (2.2) library listed for my project to link against.

For any other frustrated newbies (like me) that run into this the steps I took to resolve it are: In the Package Explorer on the left, right click on 'Android 2.2'.
Select 'Build Path->Remove from Build Path'. Right click on the project name, select 'Build Path->Configure Build Path' Click on 'Android' in the menu on the left. untick the 'Android 2.2' box, and tick the 'Android 2.3.1' box (or as appropriate). Click 'Apply' then 'OK'. Right click on the project again and select 'Build Path->Add Libraries' Select "Android Classpath Container", click 'Next'. Click 'Finish'.

Now, clear your logs, clean the project, and try a build again. Hopefully, that will work better for you as it did for me.



来源:https://stackoverflow.com/questions/10179508/androidscreenorientation-sensorlandscape-showing-error-for-a-project-with-the

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!