专栏名称: 51Testing软件测试网
51Testing软件测试网,人气最旺的软件测试技术门户,提供软件测试社区交流,软件测试博客,人才服务,测试沙龙,测试杂志,测试资料下载等全方位信息服务,是国内最专业的软件测试就业培训、企业服务供应商...
目录
相关文章推荐
51好读  ›  专栏  ›  51Testing软件测试网

说的就是它吧,安卓APP兼容测试实战总结!

51Testing软件测试网  · 公众号  · 测试  · 2019-10-28 17:30

正文


摘要


 随着移动网络的发展,手机已经成为老少皆用、必不可少的设备,手机app也被众人熟知。手机app的兼容测试显得有必要。这阵子并行进行着3项测试任务和自动化测试脚本编写,本想放弃本期的文章投稿,但在看到小编同学的友善提醒,还是争取写写近期关于安卓app兼容测试工作的实战总结。
  由于安卓手机的推陈出新,市场上安卓手机型号、安卓系统的丰富多样,在测试安卓app时候,除了功能性,同时最好用占据主流市场的各种真机进行兼容测试。


前言
  
  目前安卓市场上的主流机型主要有华为、小米、vivo、oppo、魅族、三星。安卓系统的名称颇有意思,似乎都跟甜食有关,让我们一起看看安卓的主要系统吧,从Android 4.4KitKat(奇巧巧克力)、Android 5.0Lollipop(棒棒糖)、Android5.1 Lollipop(棒棒糖)、Android 6.0Marshmallow(棉花糖)、Android 7.0Nougat(牛轧糖)、Android 8.0Oreo(奥利奥),直到目前市场上手机已经有Android 9.0Pie (派)的系统,目前Android Q(正式名称是Android 10)。安卓适配测试需要测试向上向下的兼容性。


1.了解一下向前兼容
  
  当一个应用程序发布之后,可能没过几个月 Android 系统就发布了一个新版本,当然取决于具体的发布时间。这对app意味着什么,所有东西都不能用了吗?不会的,这里谈及向前兼容。它是 Android 非常关注的事情,即用户在升级到新版 Android 的时候,用以前版本的 SDK 构建的新应用应该不会出问题。由于compileSdkVersion, minSdkVersion和 targetSdkVersion 的作用,他们可以分别控制使用哪些 API ,要求的 API 级别是什么,以及应用的兼容模式。
  下图是Android各版本对应的SDK版本。笔者所在公司的安卓app支持android4.4及其以上的手机,个人觉得以目前的手机更新换代速度,老手机几乎没有用户在用,向下兼容到4.4足矣。

  
2.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指定应用目标的API级别的一个整数。如果没有设置,默认的值等于给予的最小 minSdkVersion。

  这个属性通知系统已经针对目标版本进行了测试,系统不应该启用任何兼容性行为来维护应用程序与目标版本的正向兼容性。该应用程序仍然能够在旧版本上运行(下到minSdkVersion)
  随着Android每个新版本的发展,一些行为甚至外观可能会发生变化。但是,如果平台的API级别高于应用程序的targetSdkVersion声明的版本,则系统可能启用兼容性行为,以确保应用程序继续以您期望的方式工作。可以通过指定targetSdkVersion来匹配它所运行的平台的API级别来禁用这种兼容性行为。例如,将这个值设置为“11”或更高,允许系统在运行Android 3.0或更高版本时向应用程序应用一个新的默认主题(Holo),在运行较大屏幕时禁用屏幕兼容模式(因为对API level 11的支持隐含地支持较大屏幕)
  根据为该属性设置的值,系统可以启用许多兼容性行为。构建中相应的平台版本描述了其中的一些行为。以VERSION_CODES为参考。
  要在每个Android版本中维护应用程序,应该增加这个属性的值以匹配最新的API级别,然后在相应的平台版本上彻底测试应用程序。


3.android向前兼容主要方式
  

targetSdkVersion是android向前兼容的主要方式。

  除非更新targetSdkVersion,否则不会改变应用的行为。这允许人们在处理行为更改之前使用新的API。
  Android系统自6.0开始,提供动态权限机制,对于敏感权限(存储,定位,录音,拍照,录像等),需要在APP运行过程中动态向用户申请。

 
 

  在Android上使用动态权限,要求APP编译的目标sdk(即targetSdkVersion)为23及以上,22及以下系统会执行缺省处理(手机厂商也可能定制处理),APICloud为简便开发,默认配置targetSdkVersion为20,即走系统缺省处理,不允许更改。
  有许多原生APP转到APICloud开发后,因targetSdkVersion降级而导致无法覆盖安装。从2018年11月开始,GooglePlay要求APP编译目标sdk必须为26及以上,否则不予提交审核。
  当设置的targetSdkVersion大于等于23时,即开启了动态权限,如果你的APP带有定位,录音,拍照,录像等敏感功能时(所有权限见文档),必须使用动态权限机制,先判断是否具有该功能操作权限,再进行操作,如果不具备相应的权限,对应的功能是失效的(也可能导致崩溃)
  当你设置的targetSdkVersion大于等于23时,如果是编译自定义loader,安装到手机后,需要先在设置中给应用打开存储空间权限。否则,WiFi同步后,loader无法正常加载代码。
  为保证动态权限尽可能适配更多厂商的手机以及顺利上线Google Play,targetSdkVersion目前推荐设置为26,对应的系统为Android 8.0。


……


点击阅读原文查看全文


CONTINUE

推荐阅读

点击阅读☞手机APP测试如何进行兼容性测试?

点击阅读☞如何降低应用程序测试的成本和代价?3种方法提高资源效率!

点击阅读☞人工智能驱动的测试自动化与您的未来……

点击阅读☞手机APP测试如何进行兼容性测试?

点击阅读☞报文专项测试是什么?这次结合实例详细分析给你听!

“阅读原文”查看全文!
爱我请给我“在看”!