我正在将 Firebase 数据库 gradle 添加到我的 Android 项目中,但 gradle 无法构建。我在我的应用 gradle 中添加了 Firebase gradle,并在项目 gradle 中添加了一个 google gradle我收到此消息:
这是我的应用程序 gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "iamrajendra.github.io"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:25.3.1'
testCompile 'junit:junit:4.12'
compile 'com.google.firebase:firebase-database:11.0.2'
}
这是我的项目 gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
最佳答案
我解决了这个问题。问题是库的版本
工作库
implementation'com.google.firebase:firebase-database:10.0.0'
如果教程 android 库版本是 11.01 但该版本在 android studio 中无法运行
库不工作
com.google.firebase:firebase-database:11.0.2
教程中的 gradle 依赖项写错了。
关于android - 无法在 Android studio 中构建 firebase gradle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44987728/