库项目的构建版本高于使用它的项目 [英] Library project build version higher than projects using it

查看:59
本文介绍了库项目的构建版本高于使用它的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Android Library Project.我已将我的图书馆项目构建目标设置为11,以使用api 11并具有向前兼容性,并且我将检查min sdk版本,以便在os<上运行时应用不会崩溃.11

I am using Android Library Project. I have set my library project build target to say 11 to use api 11 and to have forward compatibility and I am putting check for min sdk version so that app will not crash when run on os < 11

我的其他项目的构建目标设置为8,所以我想知道将库项目构建版本设置为比构建目标较低的项目更高的正确方法吗?

My other projects have build target set to 8 so I want to know is it the correct way to set library project build version higher than the projects with lower build target going to use it?

现在我还没有发现任何崩溃.只是想知道具有更高构建版本的库是否可以用于具有比sdk版本更低的sdk版本的项目中.

right now I haven't observed any crash. Just wanted to know can the library with higher build version be used in projects with lower build sdk version than library.

提前谢谢.:)

推荐答案

通过在代码级别检查android版本的android.os.Build.VERSION.SDK_INT<11然后就不要运行它,但是开发指南不建议这样做:

It is probably doable by branch checking SDK version in code level like if android.os.Build.VERSION.SDK_INT < 11 then do not run this, but not recommended by dev guide:

平台版本必须低于或等于Android项目

一个库被编译为从属应用程序项目的一部分,因此该库项目中使用的API必须与用于编译该应用程序项目的Android库版本兼容.通常,库项目应使用与应用程序使用的API级别相同或更低的API级别.如果库项目使用的API级别高于应用程序的API级别,则该应用程序项目将无法编译.例如,拥有一个使用Android 1.5 API(API级别3)并且在Android 1.6(API级别4)或Android 2.1(API级别7)项目中使用的库是完全可以接受的.

A library is compiled as part of the dependent application project, so the API used in the library project must be compatible with the version of the Android library used to compile the application project. In general, the library project should use an API level that is the same as — or lower than — that used by the application. If the library project uses an API level that is higher than that of the application, the application project will not compile. It is perfectly acceptable to have a library that uses the Android 1.5 API (API level 3) and that is used in an Android 1.6 (API level 4) or Android 2.1 (API level 7) project, for instance.

这篇关于库项目的构建版本高于使用它的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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