Firebase教程1友好的聊天配置root项目'android-start'时发生错误 [英] Firebase Tutorial 1 Friendly chat Error occurred configuring root project 'android-start'
问题描述
我正在尝试启动友好聊天Firebase教程。但是Gradle构建会抛出一个错误,我不能再给出任何信息,因为我不知道从哪里开始。然而,一张图片胜过千言万语,我相信它包含了所有相关的东西。
- 从git google.json下载的文件被复制
-
$ b $添加和应用的依赖关系
- 更新构建工具和IDE b
我注意到只有一个项目
build.gradle
我找不到一个模块build.gradle
。我不知道这个问题是否与这个问题有关。
最初抛出未注册的VCS根目录的错误,我点击了添加根目录,但没有帮助。
build .gradle 文件是蓝色的,当我点击其中一个时,它会打开名为 android-start 的标签(也是蓝色),但路径是 C :\ Users \User1\friendlychat\android-start\build.gradle
,文件内容如下:
//顶级构建文件,您可以在其中添加对所有子项目/模块通用的配置选项。
$ b buildscript {
repositories {
jcenter()
mavenLocal()
}
依赖关系{
classpath'com.google .gms:google-services:3.0.0'
classpath'com.android.tools.build:gradle:2.0.0'
//注意:不要放置你的应用程序依赖关系它们属于单个模块build.gradle文件中的
//
}
}
allprojects {
repositories {
jcenter()
$ mavenLocal()
}
}
任务清理(类型:删除){
删除rootProject.buildDir
}
apply plugin:'com.google.gms.google-services'
编辑:LogCat说
配置Android SDK
如果我点击configure并设置SDK版本和构建工具版本, >
错误:(31,0)无法找到方法android()参数[build_coejwo2h3fxgj0snev4rovui4 $ _run_closure4 @ 512b9d86] on root project'android-开始类型的org.gradle.api.Project。
< a href =openFile:C:\Users\User1\friendlychat\android-start\build.gradle>打开文件< / a>
解决方案我认为错误是在project.gradle 。我解释一下,这个依赖是正确的,因为它在 project.gradle 中:
classpath 'com.google.gms:google-services:3.0.0'
需要firebase的其他依赖,需要在 app.gradle 中:
apply plugin:'com.google.gms.google -services'
而 app.gradle 也需要这个依赖:
compile'com.google.firebase:firebase-core:9.6.1'
最后的阶梯是这些, project.gradle :
<$ p
$ class $' google.gms:google-services:3.0.0'
classpath'com.android.tools.build:gradle:2.0.0'
//注意:不要在这里放置您的应用程序依赖关系;它们属于单个模块build.gradle文件中的
//
}
}
allprojects {
repositories {
jcenter()
$ mavenLocal()
}
}
任务清理(类型:删除){
删除rootProject.buildDir
}
和 app.gradle :
...
依赖关系{
编译'com.google.android.gms:play-services:9.6.1'
编译'com.google.firebase:firebase-core:9.6.1'
}
//在文档的最后
应用插件:com.google.gms。 google-services'
告诉我是否可以帮助你,问候!
I am trying to start the Friendly Chat Firebase tutorial. But the gradle build throws an error and I can't really give anymore information as I don't know where to begin. However, a picture is worth a thousand words, and I believe that it contains everything relevant.
- Files downloaded from git google.json copied across
- Dependencies added and applied
- Build tools and IDE updated
I noticed there is only a project
build.gradle
I cant find a modulebuild.gradle
. I have no idea if this has anything to do with the issue though.Originally threw error about unregistered VCS root, I clicked add root, but it didn't help.
Both
build.gradle
files are blue and when I click either one, it opens the tab named android-start(also blue), but the path isC:\Users\User1\friendlychat\android-start\build.gradle
and the file contents are:// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() mavenLocal() } dependencies { classpath 'com.google.gms:google-services:3.0.0' classpath 'com.android.tools.build:gradle:2.0.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() mavenLocal() } } task clean(type: Delete) { delete rootProject.buildDir } apply plugin: 'com.google.gms.google-services'
EDIT: LogCat says
configure Android SDK
If I click configure and set the SDK version and build tools version I get:
Error:(31, 0) Could not find method android() for arguments [build_coejwo2h3fxgj0snev4rovui4$_run_closure4@512b9d86] on root project 'android-start' of type org.gradle.api.Project. <a href="openFile:C:\Users\User1\friendlychat\android-start\build.gradle">Open File</a>
解决方案I think the error is in project.gradle... I explain about it, this dependencie is correct because is inside the project.gradle:
classpath 'com.google.gms:google-services:3.0.0'
The other dependencie that needs firebase, needs is inside app.gradle:
apply plugin: 'com.google.gms.google-services'
And the app.gradle needs too this dependence:
compile 'com.google.firebase:firebase-core:9.6.1'
The finally gradles are these, project.gradle:
buildscript { repositories { jcenter() mavenLocal() } dependencies { classpath 'com.google.gms:google-services:3.0.0' classpath 'com.android.tools.build:gradle:2.0.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() mavenLocal() } } task clean(type: Delete) { delete rootProject.buildDir }
And the app.gradle:
... dependencies { compile 'com.google.android.gms:play-services:9.6.1' compile 'com.google.firebase:firebase-core:9.6.1' } //At final of the document apply plugin: 'com.google.gms.google-services'
Tell me if I can helps you, greetings!
这篇关于Firebase教程1友好的聊天配置root项目'android-start'时发生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!