在空项目中,添加firebase后会导致以下错误:
图像版本: -
文字版: -
所有com.android.support库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃).找到版本27.1.1,25.2.0.示例包括com.android.support:animated-vector-drawable:27.1.1和com.android.support:support-media-compat:25.2.0
另一个错误:
警告:配置'compile'已过时,已被'implementation'和'api'取代.
是否有任何可能的解决方案来删除这些警告?
我的项目build.gradle是:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.1.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)
我的app build.gradle是:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.mad.android.firebasetestauth2"
minSdkVersion 24
targetSdkVersion 27
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 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-auth:11.6.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'
}
apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)
发生此错误是因为google-services正在实现一些未使用27.1.1版本的库.所以我们需要覆盖版本.
为了做到这一点,总是尝试在android studio 的终端中运行它:
./gradlew -q dependencies app:dependencies --configuration debugAndroidTestCompileClasspath
Run Code Online (Sandbox Code Playgroud)
这将显示一个依赖项列表,其中显示了它的版本号,如下所示: -
在这里,我们需要找到那些尚未被覆盖并具有25或26版本号且未覆盖到27的依赖项.
就像我们上面的例子一样 com.android.support:support-v4:25.2.0
现在我们只需要使用最新版本号将其添加到依赖项块.
最后,依赖块看起来像这样:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:support-media-compat:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-auth:12.0.1'
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'
}
Run Code Online (Sandbox Code Playgroud)
我们在这里补充
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:support-media-compat:27.1.1'
Run Code Online (Sandbox Code Playgroud)
为了解决第二个错误的
警告:配置'compile'已过时,已被'implementation'和'api'取代.
在项目build.gradle中,更新
classpath 'com.google.gms:google-services:3.1.1'
Run Code Online (Sandbox Code Playgroud)
至
classpath 'com.google.gms:google-services:3.2.0'
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1412 次 |
最近记录: |