appcompat-v7:28.0.0-beta01 更新后损坏

appcompat-v7:28.0.0-beta01 Broke after update

我是 Android studio 的初学者,昨天安装了它。然后我创建了一个运行良好的空项目。今天我不得不更新,现在我正在与错误消息作斗争:

如您所见,我已经包含了示例。我有什么办法可以解决这个问题吗? 这里是完整的 app.gradle

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "at.sumser.fateandlove"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.0.0-beta01'

    implementation 'com.android.support:support-media-compat:26.1.0'
    implementation 'com.android.support:animated-vector-drawable:28.0.0-beta01'

    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    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.google.android.gms:play-services-location:15.0.1'
}

有趣的是,它告诉我在 SDK 为 28 时添加 'com.android.support:support-media-compat:26.1.0'?有什么想法吗?

更新 这里还有 build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.2.41'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

现在 'com.android.support:support-media-compat:26.1.0' 也告诉我一个问题:

问题:Google 不测试他们的版本吗?还是 Android Studio 中的自动解析器坏了?我现在浪费了近 3 个小时来找到解决此问题的方法...

我在更新到 AppCompat 版本 28 时遇到了同样的问题。

首先我建议使用最新版本 28.0.0-rc01 而不是 28.0.0-beta01

如果你仍然收到所有库必须使用完全相同的版本规范的警告,你可以强制使用相应库的最新版本。

您可以通过向 android { } 中的应用 build.gradle 文件添加解析策略来实现此目的,如下所示:

configurations.all {
    resolutionStrategy {
        force 'com.android.support:support-v4:28.0.0-rc01'
        force 'com.android.support:support-media-compat:28.0.0-rc01'
        force 'com.android.support:customtabs:28.0.0-rc01'
    }
}