问题描述
在今天早些时候安装 Android L 开发者预览版 SDK 后,我想让我的应用与 Android L 和旧版本(例如 Jelly Bean)兼容.我的应用程序使用的 minSdkVersion 为 16,但由于我尝试了开发者预览版,Android Studio 似乎并不尊重我的 minSdkVersion.我正在尝试让我的应用程序在我的 Galaxy Nexus(API 19)上运行,这是我得到的错误:
After installing the Android L Developer Preview SDK earlier today I wanted to make my app compatible with both Android L and older versions such as Jelly Bean. My app uses a minSdkVersion of 16 but since I tried out the developer preview Android Studio doesn't seem to respect my minSdkVersion. I'm trying to get my app to run on my Galaxy Nexus (API 19) and here's the error I get:
这是我的 AndroidManifest.xml
Here's my AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.simon.holocountownapp"
android:versionCode="45"
android:versionName="4.1.1" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="L" />
...
这是我的 build.gradle:
Here's my build.gradle:
apply plugin: 'android'
android {
compileSdkVersion 'android-L'
buildToolsVersion '20'
defaultConfig {
minSdkVersion 16
targetSdkVersion 'L'
}
buildTypes {
release {
runProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
}
dependencies {
compile 'com.doomonafireball.betterpickers:library:1.5.2'
compile 'uk.co.androidalliance:edgeeffectoverride:1.0.1'
compile 'com.readystatesoftware.systembartint:systembartint:+'
compile "com.android.support:support-v4:+"
compile "com.android.support:support-v13:+"
}
推荐答案
您正在使用此依赖项:
compile "com.android.support:support-v4:+"
通过这种方式,您可以在 L-preview 中使用 support-v4 (21-rc1).
In this way you are using the support-v4 in L-preview (21-rc1).
这个支持库声明了minSdkVersion L
(你可以查看Manifest).
This support lib is declaring minSdkVersion L
(you can check the Manifest).
您必须强制 minSdkVersion 为L"(检查文档:http://developer.android.com/preview/setup-sdk.html)
You have to force the minSdkVersion to be 'L' (check the doc: http://developer.android.com/preview/setup-sdk.html)
在开发环境中,打开模块的 build.gradle 文件并确保:
On the development environment, open the build.gradle file for your module and make sure that:
compileSdkVersion is set to 'android-L'
minSdkVersion is set to 'L'
targetSdkVersion is set to 'L'
这不是错误,但这是因为这些 API 不是最终版本.这是一种防止在最终 API 21 设备上安装应用程序或使用支持库 21-r1 在商店中发布应用程序的方法.
It is not a bug, but this is because these APIs are not final. It is a way to prevent installing the apps on a final API 21 device or publishing it on the store using support lib 21-r1.
这篇关于Android Studio - 无法指定自己的 minSdkVersion的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!