我在我的项目中添加了Firebase In-app消息。使用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。
关于:
所有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'