ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

编译版本与最低要求版本Android

2019-06-20 13:10:44  阅读:438  来源: 互联网

标签:android android-custom-view android-version


在我的自定义视图中,我使用的方法是drawTextOnPath(…),直到4.1才支持硬件加速.

所以我想添加一个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’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.

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-custom-view,android-version
来源: https://codeday.me/bug/20190620/1244502.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有