
所以我想添加一个if语句,它在运行时检查当前的Android版本,并在此版本大于或等于4.1时打开硬件加速.
我的问题是我使用AndroID 4.0 SDK(这是我的最低版本)编译我的项目,所以我没有AndroID 4.1的Build.VERSION_CODES.
虽然我的最低版本是4.0,但我应该用4.1编译我的项目吗?
解决方法 我写了一次: Android targeting system重要部分:
When compiling a Java application with a Java 7 compiler,you can’t
use it with a Java 6 interpreter. The interpreter will tell you,that
it can’t interpret the produced byte-code,even thought you’re not
using any Java 7 language features. If you want to compile with the
latest compiler but make your byte-code runnable on older JVM
instances,you’ll need to tell the compiler to do so (using the
-target-flag).In AndroID,you can declare what platform-versions you support in your
manifest-file,using the<uses-sdk>-element and it’sandroID:minSdkVersionandandroID:targetSdkVersion-attributes. The
difference between those “targeting mechanics” is,that AndroID does
not care against which platform version the application was compiled.If you declare your application to be compatible with API Level 4,
AndroID will happily install it,even if you compiled it against
AndroID 4.1 (API Level 16).
简而言之:
If you want your application to work with the newest AndroID platform,build against it. Use minSdkVersion to declare the lowest API Level which is supported by your application. As your targetSdkVersion,use the API Level against which you compiled the application. Use 07001 to check for (possibly) unsupported API calls. Use conditional execution and the @TargetAPI-annotation to use newer APIs when available.
当您使用最新的SDK构建应用程序时,您将拥有所有可用的Build.VERSION_CODES.
总结以上是内存溢出为你收集整理的编译版本与最低要求版本Android全部内容,希望文章能够帮你解决编译版本与最低要求版本Android所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)