java - 如何成功提高目标api级别
问题描述
我想增加我的应用程序的目标 api 级别,而不影响应用程序依赖的其他库,例如 firebase 等。我尝试在 app 模块下的项目结构中更改它,但这没有成功。gradle 文件没有任何变化 我的下一个选择是通过编辑 gradle 文件本身并增加到 api 级别 28 来增加它。但是我害怕这可能对其他库产生影响。以下是我的构建 gradle 文件,请帮助我。
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.chomba.haroldking.kuta"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation ' com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.jakewharton.threetenabp:threetenabp:1.2.1'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.firebaseui:firebase-ui-database:3.1.0'
implementation 'com.android.support:palette-v7:26.1.0'
implementation 'com.wdullaer:materialdatetimepicker:3.1.3'
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.google.firebase:firebase-storage:16.0.1'
}
apply plugin: 'com.google.gms.google-services'
我需要对其他库进行更改吗
解决方案
要升级你的targetSdkVersion
,你应该把它和build.gradle
一起更新compileSdkVersion
(如果你不更新它,你会得到一个错误)。
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
}
}
更新targetSdkVersion
和 后,compileSdkVersion
您还需要将支持库版本更新为28.0.0
,因为支持库的主要版本需要与targetSdkVersion
. 例如:
implementation 'com.android.support:appcompat-v7:28.0.0' // instead of 26.1.0
版本28.0.0
是支持库的最终版本。要在升级到 API 29 后继续使用支持库,您应该迁移到AndroidX。
更新时,您还应该检查Android 9中是否有您需要考虑的相关更改。
在您的情况下,如果不更新targetSdkVersion
依赖项,您将无法更新。
推荐阅读
- mysql - MySQL 不会在 XAMPP 上启动
- javascript - 优雅的 JSON.parse 异常处理程序
- r - “如果”有两个条件错误
- graph - 按传入顶点对边属性和分组求和
- javascript - 上传时出错,但不是错误
- javascript - 未捕获的类型错误:无法读取未定义的属性“长度” - jQuery
- c++ - 模板参数 SFINAE 不使用模板参数
- android - 为什么 Kotlin 编译器在有效的 IF 语句中给出错误?
- react-native - 我在哪里可以托管 expo 项目,以便我的团队可以通过 expo 应用程序访问它
- excel - Sumifs 用于过滤数字的文本值