简体   繁体   English

Android最低SDK问题

[英]Android Minimum SDK Issue

I have a function that I need to use, but I need to set my minimum SDK up to 23 in order to use it. 我有一个需要使用的功能,但是我需要将最小SDK设置为23,才能使用它。 Problem is, our application runs on a lot of lower SDK devices out there in the wild. 问题是,我们的应用程序通常在许多较低的SDK设备上运行。 Is there any way I can setup my project to allow me to compile the application while still using a lower minimum SDK target? 有什么方法可以设置项目以允许我在仍然使用较低的最低SDK目标的情况下编译应用程序?

最低SDK问题

I have a function that I need to use, but I need to set my minimum SDK up to 23 in order to use it. 我有一个需要使用的功能,但是我需要将最小SDK设置为23,才能使用它。

You need to set your compileSdkVersion to 23. 您需要将compileSdkVersion设置为23。

Is there any way I can setup my project to allow me to compile the application while still using a lower minimum SDK target? 有什么方法可以设置项目以允许我在仍然使用较低的最低SDK目标的情况下编译应用程序?

Set your minSdkVersion to whatever you want. 将您的minSdkVersion设置为您想要的任何值。 Set your compileSdkVersion to 23 or higher. 将您的compileSdkVersion设置为23或更高。 Then, make sure that you only call canDrawOverlays() on API Level 23+ devices, such as by checking Build.VERSION.SDK_INT . 然后,确保仅在API Level 23+设备上调用canDrawOverlays() ,例如通过检查Build.VERSION.SDK_INT

Check that the api is 23 or greater before trying to call this function: 在尝试调用此函数之前,请检查api是否为23或更高版本:

if (android.os.Build.VERSION.SDK_INT >= 23) {
    Settings.canDrawOverlays(this);
} else {
// I don't think you need to do anything, I believe canDrawOverlays is 
//functionally true for older APIs
}

Have you already had a look at the Supporting Different Platform Versions page? 您是否已经查看了“ 支持不同的平台版本”页面?

If you want to use the method canDrawOverlays(...) on ALL platforms, then you simply can't: it's only supported in the API starting from version 23. However, if you want to use this api ONLY when the platform version >= 23 (meaning: only on those devices with AT LEAST Marshmallow installed), then you can: 如果要在所有平台上使用canDrawOverlays(...)方法,则根本不能:从版本23开始仅在API中支持该方法。但是,如果仅当平台版本> = 23(意味着:仅在安装了AT LEAST Marshmallow的设备上),您可以:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.MARSHMALLOW) {
    Settings.canDrawOverlays(...)
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM