0

我在我的项目中添加了 Firebase 应用内消息传递。使用 Gradle 文件同步项目是成功的,但是当我运行应用程序时,它会抛出错误:

e: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:

并且对于

implementation 'com.android.support:appcompat-v7:26.1.0'

它显示以下错误

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.1.1, 26.1.0. Examples include com.android.support:animated-vector-drawable:27.1.1 and com.android.support:cardview-v7:26.1.0 less... (⌘F1) 
There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion).
Issue id: GradleCompatible

我的 Gradle 文件是:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

buildscript {
ext.kotlin_version = '1.3.11'

repositories {
    jcenter()
}
dependencies {
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

android {
flavorDimensions "default"

signingConfigs {
    defaultconfig {
        keyAlias 'key'
        keyPassword 'abc'
        storeFile file('./dev.keystore')
        storePassword 'abc'
    }
    prod {
        keyAlias 'key'
        keyPassword 'xyz'
        storeFile file('./src/free_prod/prod.keystore')
        storePassword 'abc'
    }
}
compileSdkVersion 26
defaultConfig {
    versionCode 50
    versionName "1.1.50.04"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    vectorDrawables.useSupportLibrary = true
    signingConfig signingConfigs.defaultconfig
    multiDexEnabled true
}
buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    debug {
    }
}
productFlavors {
    free_stage {
        minSdkVersion 16
        applicationId 'com.abc.xyz'
        targetSdkVersion 26
        versionNameSuffix '.free'
        signingConfig signingConfigs.prod
    }
    free_prod {
        minSdkVersion 16
        applicationId 'com.abc.xyz'
        targetSdkVersion 26
        versionNameSuffix '.free'
        signingConfig signingConfigs.prod
    }
    free_dev {
        versionNameSuffix '.free.dev'
        signingConfig signingConfigs.defaultconfig
        applicationId 'com.abc.xyz'
        minSdkVersion 16
        targetSdkVersion 26
    }
}
buildToolsVersion '28.0.3'
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:support-vector-drawable:26.1.0'
implementation 'com.android.support:customtabs:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.google.firebase:firebase-auth:12.0.1'
implementation 'com.google.android.gms:play-services-auth:12.0.1'
implementation 'com.google.code.gson:gson:2.8.2'
implementation project(':facebook')
implementation project(':facebook-login')
implementation project(':facebook-common')
implementation project(':facebook-core')
implementation 'com.parse.bolts:bolts-tasks:1.4.0'
implementation 'com.parse.bolts:bolts-applinks:1.4.0'
implementation 'com.google.firebase:firebase-perf:12.0.1'
implementation 'com.firebase:firebase-jobdispatcher:0.8.5'
implementation 'com.android.support:gridlayout-v7:26.1.0'
implementation 'com.google.firebase:firebase-messaging:12.0.1'
implementation 'com.google.firebase:firebase-invites:12.0.1'
implementation 'com.google.firebase:firebase-dynamic-links:12.0.1'
implementation 'com.google.firebase:firebase-inappmessaging-display:17.0.5'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.1'
implementation 'com.jakewharton.timber:timber:4.7.0'
implementation 'com.google.android.gms:play-services-ads:12.0.1'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
implementation 'io.reactivex.rxjava2:rxjava:2.1.14'
implementation 'android.arch.lifecycle:extensions:1.1.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'org.jetbrains.kotlin:kotlin-stdlib'
implementation 'com.android.support:multidex:1.0.1'
implementation 'com.google.firebase:firebase-core:12.0.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.0'
def room_version = "1.1.1"
implementation "android.arch.persistence.room:runtime:$room_version"
annotationProcessor "android.arch.persistence.room:compiler:$room_version"

debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.3'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.3'
// Optional, if you use support library fragments:
debugImplementation 'com.squareup.leakcanary:leakcanary-support-fragment:1.6.3'
 }

 apply plugin: 'com.google.gms.google-services'
 apply plugin: 'com.google.firebase.firebase-perf'
 apply plugin: 'io.fabric'

下面是我的项目 gradle 文件。

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

buildscript {

repositories {
    google()
    jcenter()
    mavenCentral()
    maven { url 'https://maven.fabric.io/public' }

}
dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'
    classpath 'com.google.gms:google-services:3.0.0'
    classpath 'com.google.firebase:firebase-plugins:1.1.5'
    classpath 'io.fabric.tools:gradle:1.25.4'
    //classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}
allprojects {
repositories {
    google()
    jcenter()
    maven {
        url 'https://maven.google.com/'
    }
    }
    }

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

无法修复我的错误,我尝试更新我的 Gradle 和 api。

4

1 回答 1

0

关于:

所有 com.android.support 库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)。找到版本 27.1.1、26.1.0。示例包括 com.android.support:animated-vector-drawable:27.1.1 和 com.android.support:cardview-v7:26.1.0 less... (⌘F1) 有一些库的组合,或者工具和库,不兼容或可能导致错误。一种这样的不兼容性是使用不是最新版本的 Android 支持库版本(或者特别是低于您的 targetSdkVersion 的版本)进行编译。问题 ID:GradleCompatible

这可能是因为 firebase 库正在使用支持库 27.1.1。

将所有您支持的库移至27.1.1

implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:support-vector-drawable:27.1.1'
implementation 'com.android.support:customtabs:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:gridlayout-v7:27.1.1'
于 2019-03-18T18:39:20.283 回答