我在位置部分的Android Studio中导入了示例应用。然后我继续更新大部分依赖项。然后我尝试添加Firebase,当事情向南时。模块build.gradle在下面。
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
}
}
apply plugin: 'com.android.application'
repositories {
jcenter()
}
dependencies {
compile 'com.google.android.gms:play-services-location:10.0.1'
compile 'com.google.android.gms:play-services-maps:10.0.1'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.google.maps.android:android-maps-utils:0.4.4'
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.android.support:recyclerview-v7:25.0.1'
compile 'com.android.support:design:25.0.1'
compile 'com.google.android.gms:play-services-wearable:10.0.1'
compile 'com.android.support:support-v13:25.0.1'
compile project(':Shared')
wearApp project(':Wearable')
}
// The sample build uses multiple directories to
// keep boilerplate and common code separate from
// the main sample code.
List<String> dirs = [
'main', // main sample code; look here for the interesting stuff.
'common', // components that are reused by multiple samples
'template'] // boilerplate code that is generated by the sample template process
android {
compileSdkVersion 25
buildToolsVersion '24.0.2'
defaultConfig {
minSdkVersion 18
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
sourceSets {
main {
dirs.each { dir ->
java.srcDirs "src/${dir}/java"
res.srcDirs "src/${dir}/res"
}
}
androidTest.setRoot('tests')
androidTest.java.srcDirs = ['tests/src']
}
productFlavors {
}
}
apply plugin: 'com.google.gms.google-services'
根build.gradle在下面。
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:3.0.0'
}
}
我收到的错误是:
错误:找不到com.google.gms:google-services:3.0.0。 在以下位置搜索: file:/ C:/ Android / Android Studio / gradle / m2repository / com / google / gms / google-services / 3.0.0 / google-services-3.0.0.pom file:/ C:/ Android / Android Studio / gradle / m2repository / com / google / gms / google-services / 3.0.0 / google-services-3.0.0.jar 要求: :ToledoZoo:未指定
使用最新的SDK,以及所有。还将google.json文件添加到了app目录中。我相信这是我想念的小事,但是......还是错过了它!
答案 0 :(得分:3)
模块build.gradle位于
之下
app/
是一个模块,buildscript
块不应该在此范围内。
app build.gradle位于下方。
如果这样,您的意思是项目的 root 中的build.gradle
,那么您可以在该文件中添加播放服务的classpath
。
参考。 https://firebase.google.com/docs/android/setup#add_the_sdk
注意,当文档说
时buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:3.0.0'
}
你不会真正复制// ...
件。这意味着&#34;留下已经存在的东西&#34;。
如果您有一个单独的模块Gradle项目,那么查看您的问题可能会有意义,因此您需要
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.google.gms:google-services:3.0.0'
}
}
apply plugin: 'com.android.application'
// rest of gradle file