编译版本对最低版本的Andr​​oid [英] Compiled version vs. Minimum required version Android

查看:566
本文介绍了编译版本对最低版本的Andr​​oid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的自定义视图我使用的方法 drawTextOnPath(...)不支持硬件加速至4.1。

In my custom view I'm using the method drawTextOnPath(...) which is not supported for hardware acceleration until 4.1.

所以,我想补充一个如果语句用于检查上运行当前的Andr​​oid版本并开启硬件加速,如果这个版本是大于或等于4.1。 我的问题是,我编译我与Android 4.0 SDK项目(这是我的最低版本),所以我没有 Build.VERSION_ codeS 为Android 4.1

So I wanted to add an if statement which checks the current Android version on runtime and turns the hardware acceleration on if this version is greater or equals to 4.1. My problem is that I compile my project with Android 4.0 SDK (which is my minimum version), so I don't have the Build.VERSION_CODES for Android 4.1.

我应该编译我的项目4.1虽然我的最低版本是4.0?

Should I compile my project with 4.1 although my minimum version is 4.0 ?

推荐答案

我写了一次:机器人瞄准系统

重要部分:

在编译Java应用程序使用Java 7的编译器,你不能   用它与Java 6间preTER。间preTER会告诉你,   它不能跨preT所产生的字节级code,甚至认为你不   使用任何Java 7语言特性。如果你要编译与   最新的编译器,但让你针对字节code可运行在较旧的JVM   情况下,你需要告诉编译器这样做(用   -target旗)。

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).

在Android中,你可以声明你支持什么平台版本的   清单文件,使用<采用-SDK> k-元,它的   安卓的minSdkVersion 机器人:targetSdkVersion -attributes 的   这些瞄准机制之间的区别是,Android的做   不管对哪个平台版本的应用程序被编译。

In Android, you can declare what platform-versions you support in your manifest-file, using the <uses-sdk>-element and it’s android:minSdkVersion and android:targetSdkVersion-attributes. The difference between those "targeting mechanics" is, that Android does not care against which platform version the application was compiled.

如果您声明您的应用程序与API级别4兼容,   Android将高兴地安装它,即使你编译它反对   的Andr​​oid 4.1(API等级16)。

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).

因此​​,在短期:

      
  • 如果您希望您的应用程序与最新的Andr​​oid平台工作,建立反对。
  •   
  • 使用的minSdkVersion声明这是支持你的应用程序的最低API级别。
  •   
  • 如您targetSdkVersion,使用API​​水平,使您编译的应用程序。
  •   
  • 使用 [机器人]林特检查(可能)不支持API调用。
  •   
  • 使用条件执行和@ TargetApi注解可用时使用新的API。
  •   
  • 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 [Android] Lint to check for (possibly) unsupported API calls.
  • Use conditional execution and the @TargetApi-annotation to use newer APIs when available.

当你正在构建与最新的SDK应用程序,你将拥有所有的 Build.VERSION_ codeS 可用。

When you're building your application with the newest SDK, you'll have all the Build.VERSION_CODES available.

这篇关于编译版本对最低版本的Andr​​oid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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