android - Android SDK 从 23 升级到 26 构建错误
问题描述
使用 SDK 版本 23 时,我的应用程序运行良好。我尝试将其升级到 SDK 版本 26,但出现构建错误。构建 gradle 文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.0'
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/CHANGES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
defaultConfig {
applicationId "com.futuremobilitylabs.incentrip"
minSdkVersion 19
targetSdkVersion 26
versionCode 82
versionName "0.8.113"
multiDexEnabled true
testInstrumentationRunner "com.android.test.runner.MultiDexTestRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "2048M"
}
configurations {
all*.exclude module: 'mediarouter-v7'
all*.exclude module: 'support-compat'
compile.exclude group: "org.apache.httpcomponents", module: "httpclient"
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
//compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
// http://jakewharton.github.io/butterknife/
// https://github.com/daimajia/AndroidSwipeLayout
//compile "com.daimajia.swipelayout:library:1.2.0@aar"
compile 'ch.acra:acra:4.9.1'
compile 'com.android.support:appcompat-v7:26.0.0'
compile 'com.android.support:design:26.0.0'
compile 'com.android.support:recyclerview-v7:26.0.0'
compile 'com.android.support:support-v4:26.0.0'
compile 'com.android.support:multidex:1.0.0'
compile 'com.google.android.gms:play-services:10.2.0'
compile 'com.google.android.gms:play-services-gcm:10.2.0'
compile 'com.google.android.gms:play-services-ads:10.2.0'
compile 'com.google.android.gms:play-services-auth:10.2.0'
compile 'com.google.maps.android:android-maps-utils:0.3.+'
compile 'de.hdodenhof:circleimageview:1.3.0'
compile 'com.jakewharton:butterknife:8.5.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.uber.sdk:rides-android:0.5.3'
compile 'com.google.code.gson:gson:2.8.1'
compile 'org.jsoup:jsoup:1.10.3'
testCompile 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
}
apply plugin: 'com.google.gms.google-services'
我得到的构建错误:
build failed 8s 664ms Run build 8s 531ms Load build 12ms Configure build 110ms 计算任务图 98ms Run tasks 8s 307ms 指定的 Android SDK Build Tools 版本 (26.0.0) 被忽略,因为它低于支持的最低版本 (26.0.2)适用于 Android Gradle 插件 3.0.1。将使用 Android SDK Build Tools 26.0.2。要抑制此警告,请从您的 build.gradle 文件中删除“buildToolsVersion '26.0.0'”,因为每个版本的 Android Gradle 插件现在都有一个默认版本的构建工具。找不到资源样式/TextAppearance.Compat.Notification.Info(又名 com.app.application:style/TextAppearance.Compat.Notification.Info)。找不到资源样式/TextAppearance.Compat.Notification(又名 com.app.application:style/TextAppearance.Compat.Notification)。找不到资源样式/TextAppearance.Compat.Notification.Time(又名 com.app.application:style/TextAppearance.Compat.Notification.Time)。找不到资源样式/TextAppearance.Compat.Notification.Title(又名 com.app.application:style/TextAppearance.Compat.Notification.Title)。链接参考失败。
java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 错误:检查日志了解详细信息 java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception : AAPT2 错误:检查日志以获取详细信息 com.android.tools.aapt2.Aapt2Exception:AAPT2 错误:检查日志以获取详细信息
我已阅读一些帖子但无法解决此问题:Android SDK 26 build error , Failed to resolve: com.android.support:appcompat-v7:27.+ (Dependency Error)
我该如何解决这个问题?
解决方案
问题出在下面一行。
all*.exclude module: 'support-compat'
删除它并使用以下代码排除 support-v4 库。
all*.exclude module: 'support-v4'
或者
all*.exclude group: 'com.android.support', module: 'support-v4'
您还可以从特定库中排除 support-v4,如下所示:
compile ('com.jakewharton:butterknife:8.5.1'){
exclude group: 'com.android.support', module:'support-v4'
}
推荐阅读
- python - 覆盖父类 Django admin 中定义的操作
- amazon-web-services - 如何从 ec2 实例中的 shell 脚本调用 lambda
- python - DRF JWT 身份验证对象没有属性“id”
- flutter - 与 Dismissible 一起使用时 Flutter Streambuilder 太快了
- docker - Couchdb docker 容器退出,代码为 137,但 docker 状态显示 OOMKilled false
- mongodb - mongo-c-driver中的bson:更新已存在字段的值
- r - 使用自己的内容创建动态选项卡
- reactjs - React 延迟组件卸载,直到下一个组件准备好渲染
- android - 如何将多个选定项目从 Recyclerview 传递到 Activity?
- c# - Xamarin 应用程序在实现 MasterDetailPage 后无任何异常崩溃