Android 面试 - compileSdkVersion、minSdkVersion、targetSdkVersion、buildToolsVersion

一般来说,选择跟compileSdkVersion同一个大版本下的最新稳定版本即可,如下图里我已经下载了这么多版本的Build-Tools,在新开发App时我会选择28.0.3版本。

在这里插入图片描述

minSdkVersion


An integer designating the minimum API Level required for the

application to run. The Android system will prevent the user from

installing the application if the system’s API Level is lower than the

value specified in this attribute. You should always declare this

attribute.

Caution: If you do not declare this attribute, the system assumes a

default value of “1”, which indicates that your application is

compatible with all versions of Android. If your application is not

compatible with all versions (for instance, it uses APIs introduced in

API Level 3) and you have not declared the proper minSdkVersion, then

when installed on a system with an API Level less than 3, the

application will crash during runtime when attempting to access the

unavailable APIs. For this reason, be certain to declare the

appropriate API Level in theminSdkVersion attribute.

minSdkVersion指定了App运行所需最低的API级别,比如你设置它为23(Android 6.0),那么该App不能在低于Android6.0版本的设备上安装。从理论上来说,如果你设置minSdkVersion为1,则可以最低兼容到最早的Android版本——然而,这就意味着你要为老设备的兼容做大量的工作,显然并不可取,毕竟从统计上来说已经没有人用那么老的设备了。

一般来说,我们通过一些统计结果,以及本公司App的用户分析,来决定最低兼容版本。

根据Google Play的统计,截止到2018年10月26日,使用Android 4.4及以上版本的设备大概占了96.5%,而5.0及以上的则占了接近89%,所以最低版本兼容到4.4就基本上问题不大了。实际上一些老设备的活跃度会比较差,从这个角度考虑,直接从5.0开始做兼容也是可以的。

而用户分析则指的是,App面向的用户的特征。比如用户群体主要是30岁左右的白领,那么这些用户普遍换手机的频率较高,基本上都能追着比较新的Android版本,那么minSdkVersion设置的比较高也问题不大;而如果用户群体面向50甚至60岁以上的中老年人,这些用户对换手机、升级系统不是很感冒,所以有必要把minSdkVersion设置的低一些。

记住,千万不要忘了设置minSdkVersion,如果你不设置,那么就变成了默认值:1,然后你使用的任何在Android 1.0之后才加入的特性,在1.0上运行就崩溃了。

targetSdkVersion


An integer designating the API Level that the application targets. If

not set, the default value equals that given to minSdkVersion.

This attribute informs the system that you have tested against the

target version and the system should not enable any compatibility

behaviors to maintain your app’s forward-compatibility with the target

version. The application is still able to run on older versions (down

to minSdkVersion).

As Android evolves with each new version, some behaviors and even

appearances might change. However, if the API level of the platform is

higher than the version declared by your app’s targetSdkVersion, the

system may enable compatibility behaviors to ensure that your app

continues to work the way you expect. You can disable such

compatibility behaviors by specifying targetSdkVersion to match the

API level of the platform on which it’s running. For example, setting

this value to “11” or higher allows the system to apply a new default

theme (Holo) to your app when running on Android 3.0 or higher and

also disables screen compatibility mode when running on larger screens

(because support for API level 11 implicitly supports larger screens).

There are many compatibility behaviors that the system may enable

based on the value you set for this attribute. Several of these

behaviors are described by the corresponding platform versions in the

Build.VERSION_CODES reference.

To maintain your application along with each Android release, you

should increase the value of this attribute to match the latest API

level, then thoroughly test your application on the corresponding

platform version.

targetSdkVersion完全可以按照它的字面意思去理解:目标sdkVersion。如果没有设置,则默认值为minSdkVersion。当你设置了targetSdkVersion的时候,表示你已经充分测试过了你的App在该目标版本的运行情况,系统不应该启用任何兼容性行为来保持你的App与目标版本的向前兼容性。

如果系统的API级别高于应用的目标版本,则系统会启用兼容性行为来确保应用在更高版本系统上的运行。这一点相信做Android开发时间比较久的人都很理解了,只要你写的程序比较规矩,没有太多的官方推荐外的行为,那么一个老版本的应用放在几年后的Android新设备上依然能顺利运行,只不过相当多的开发者(尤其是国内的)并不是很遵守规范罢了。

再详细说说

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数Android工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年Android移动开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
img
img
img
img
img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Android开发知识点,真正体系化!

由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新

如果你觉得这些内容对你有帮助,可以添加V获取:vip204888 (备注Android)
img

《设计思想解读开源框架》

第一章、 热修复设计

  • 第一节、 AOT/JIT & dexopt 与 dex2oat

  • 第二节、 热修复设计之 CLASS_ISPREVERIFIED 问题

  • 第三节、热修复设计之热修复原理

  • 第四节、Tinker 的集成与使用(自动补丁包生成)

    第二章、 插件化框架设计

  • 第一节、 Class 文件与 Dex 文件的结构解读

  • 第二节、 Android 资源加载机制详解

  • 第三节、 四大组件调用原理

  • 第四节、 so 文件加载机制

  • 第五节、 Android 系统服务实现原理

    第三章、 组件化框架设计

  • 第一节、阿里巴巴开源路由框——ARouter 原理分析

  • 第二节、APT 编译时期自动生成代码&动态类加载

  • 第三节、 Java SPI 机制

  • 第四节、 AOP&IOC

  • 第五节、 手写组件化架构

    第四章、图片加载框架

  • 第一节、图片加载框架选型

  • 第二节、Glide 原理分析

  • 第三节、手写图片加载框架实战

    第五章、网络访问框架设计

  • 第一节、网络通信必备基础

  • 第二节、OkHttp 源码解读

  • 第三节、Retrofit 源码解析

    第六章、 RXJava 响应式编程框架设计

  • 第一节、链式调用

  • 第二节、 扩展的观察者模式

  • 第三节、事件变换设计

  • 第四节、Scheduler 线程控制

    第七章、 IOC 架构设计

  • 第一节、 依赖注入与控制反转

  • 第二节、ButterKnife 原理上篇、中篇、下篇

  • 第三节、Dagger 架构设计核心解密

    第八章、 Android 架构组件 Jetpack

  • 第一节、 LiveData 原理

  • 第二节、 Navigation 如何解决 tabLayout 问题

  • 第三节、 ViewModel 如何感知 View 生命周期及内核原理

  • 第四节、 Room 架构方式方法

  • 第五节、 dataBinding 为什么能够支持 MVVM

  • 第六节、 WorkManager 内核揭秘

  • 第七节、 Lifecycles 生命周期


    本文包含不同方向的自学编程路线、面试题集合/面经、及系列技术文章等,资源持续更新中…

**

  • 第四节、 Room 架构方式方法

  • 第五节、 dataBinding 为什么能够支持 MVVM

  • 第六节、 WorkManager 内核揭秘

  • 第七节、 Lifecycles 生命周期

    [外链图片转存中…(img-ZPENGOmB-1711911733297)]
    本文包含不同方向的自学编程路线、面试题集合/面经、及系列技术文章等,资源持续更新中…
    [外链图片转存中…(img-GfJRLfk1-1711911733297)]

本文已被CODING开源项目:《Android学习笔记总结+移动架构视频+大厂面试真题+项目实战源码》收录

  • 23
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值