【问题标题】:Android SDK upgrade from 23 to 26 build errorAndroid SDK 从 23 升级到 26 构建错误
【发布时间】:2018-07-09 13:05:36
【问题描述】:

我的应用程序在使用 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'

我得到的构建错误:

构建失败 8s 664ms 运行构建 8s 531ms 加载构建 12ms 配置 build 110ms 计算任务图 98ms 运行任务 8s 307ms 指定的 Android SDK Build Tools 版本 (26.0.0) 被忽略,因为它 低于 Android Gradle 的最低支持版本 (26.0.2) 插件 3.0.1。将使用 Android SDK Build Tools 26.0.2。到 禁止显示此警告,从您的 build.gradle 文件,现在作为每个版本的 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 errorFailed to resolve: com.android.support:appcompat-v7:27.+ (Dependency Error)

我该如何解决这个问题?

【问题讨论】:

  • 要禁止显示此警告,请从您的 build.gradle 文件中删除“buildToolsVersion '26.0.0'”,因为每个版本的 Android Gradle 插件现在都有一个默认版本的构建工具。 试试你的错误日志中给出的这个。
  • @ZUNJAE 我检查了帖子。但是,我没有在项目中使用 android:textAppearance="@style/TextAppearance.AppCompat.Notification" 。相反,我使用了 android:textAppearance="?android:attr/textAppearanceMedium"。所以我无法解决这个问题。
  • @VirajPatel 谢谢。我可以通过这样做来抑制警告。您对修复这些错误有什么建议吗?

标签: android gradle android-gradle-plugin


【解决方案1】:

问题出在下面一行。

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'
    }

【讨论】:

  • 谢谢!我听从了你的第一个建议。原来的构建错误消失了。但是,我收到以下其他错误:错误:无法访问 android.support.v4.app.TaskStackBuilder 的 TaskStackBuilder 类文件未找到。错误:无法访问 android.support.v4.app.FragmentActivity 找不到的 FragmentActivity 类文件。错误:找不到符号类片段。错误:找不到符号类 LoaderManager。我想那是因为我确实使用了这个模块中的很多功能,但排除了“support-v4”。任何建议如何解决这个问题?谢谢
  • @LiangTang 删除 configurations {...} 代码并从单个库中排除 support-v4 库,如上文针对黄油刀库所述。不推荐使用configurations {...}
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-11-12
  • 1970-01-01
  • 2019-05-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多