我想将 Android Studio 中的最低 SDK 版本从 API 12 更改为 API 14。我尝试在清单文件中更改它,即
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="18" />
并重建项目,但我仍然发现 Android Studio IDE 抛出一些错误。我想我必须在“项目属性”或类似的内容中设置最小 SDK,以便 IDE 识别更改,但我找不到在 Android Studio 中完成此操作的位置。
当您想要更新现有 Android 项目中的 minSdkVersion 时...
-
Update
build.gradle (Module: YourProject)
under 摇篮脚本 and
确保它是NOT build.gradle (Project: YourProject.app)
.
build.gradle 的示例:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "28.0.2"
defaultConfig {
applicationId "com.stackoverflow.answer"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dependencies {
androidTestCompile 'junit:junit:4.12'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
-
同步渐变按钮(刷新所有 gradle 项目也有效)。
![enter image description here](https://i.stack.imgur.com/m5gLC.png)
or
![enter image description here](https://i.stack.imgur.com/6wS2Y.png)
- 重建项目
After更新构建.gradle's minSdkVersion
,您必须单击按钮来同步 gradle 文件(“Sync Project with Gradle files”)。这将清除标记。
更新中清单文件,例如在 Android Studio 中不再需要删除清单文件中对 SDK 级别的任何引用。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)