编译SDK是否会影响Android函数返回的值? [英] Does the compile SDK affect values returned by Android functions?

查看:78
本文介绍了编译SDK是否会影响Android函数返回的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们假设我拥有设备A,并且我的应用程序已编译两次:第一次设置compileSDK = 8,第二次设置compileSDK = 22.当我现在从Android系统调用函数时,系统是否有可能返回两个不同的值或对象?我认为这是不可能的,因为这取决于设备上运行的系统,并且针对编译SDK的编译过程只会声明它可以工作-但我的一位同事指出这可能在此处具有不同的输出.(很抱歉,这里没有任何示例.)

Lets assume I am having a device A and my app is compiled two times: first time I set compileSDK=8, second time i set compileSDK=22. When I am now calling a function from the Android system would it be possible that the system returns two different values or objects? I think this is not possible as this depends on the system running on the device and the compile process against a compile SDK only does assert that it works - but one of my collegues states that this might be possible to have different outputs here. (Sorry for not having any examples here..)

推荐答案

编译版本仅告诉您的编译器哪些android类和函数可用.例如如果您尝试使用v11中引入的方法,并且编译版本为8,则会出现编译错误.

Compile version simply tells your compiler which android classes and functions are available. e.g. If you attempt to use a method introduced in v11 and your compile version is 8, then you'll get a compilation error.

我想如果常量值在8到11之间变化,它可能会以与您的应用程序不同的方式进行编译,但这不太可能,因为android开发人员会知道会导致的问题,并且会破坏其原理.向前兼容性:

I suppose if there was a constant value that changed between 8 and 11, it could get compiled in differently to your app, but this is unlikely because the android developers would know the problems that would cause and it would break their principle of forward compatibility:

由于几乎所有对框架API的更改都是附加的,因此使用任何给定版本的API(由其API级别指定)开发的Android应用程序都可以与更高版本的Android平台和更高级别的API向前兼容./p>

Because almost all changes to the framework API are additive, an Android application developed using any given version of the API (as specified by its API Level) is forward-compatible with later versions of the Android platform and higher API levels.

即使如此,此处是:

通常,应根据应用程序可以支持的平台的最低版本来编译应用程序.

In general, you should compile your application against the lowest possible version of the platform that your application can support.

即编译版本=最低SDK版本

i.e. compile version = min sdk version

(注意,当您需要更高版本的API中的API功能时,这是一个例外,但是您打算通过检查

(Note, one exception would to this would be when you need API features from later API, but you intend to safely fall back by checking Build.VERSION. In that case you need a higher compile version than the minimum).

要陈述您的观点:

我认为这是不可能的,因为这取决于运行的系统

I think this is not possible as this depends on the system running

请务必注意,API高于 targetSdkVersion 的设备将尝试模拟至更低的

It's important to note that devices with an API higher than the targetSdkVersion will attempt emulate down to the lower target API level:

随着Android随每个新版本的发展而变化,某些行为甚至外观可能会发生变化.但是,如果平台的API级别高于应用程序的 targetSdkVersion 声明的版本,则系统可能会启用兼容性行为,以确保您的应用程序继续按您期望的方式运行.

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.

这篇关于编译SDK是否会影响Android函数返回的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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