我正试图让FCM'和' GcmListenerService' work,我将所需的依赖项添加到gradle文件,如下所示。 但当我试图建立项目时,我收到了以下发布的错误..
请让mek知道如何解决它
build.gradle app :
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':appcompat')
compile project(':securepreferences')
compile 'com.android.support:support-v4:25.2.0' // .0.1
compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.github.chrisbanes.photoview:library:1.2.4'
compile 'com.google.code.gson:gson:2.7'
compile 'com.squareup:otto:1.3.8'
compile 'com.squareup.okhttp:okhttp:2.2.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.0' // 7.5'
compile 'com.squareup.picasso:picasso:2.4.0'
compile 'com.squareup.retrofit:retrofit:1.8.0'
compile files('app/libs/android-viewbadger.jar')
compile files('app/libs/iDappsImagesLib_v0.2.jar')
compile files('app/libs/iDappsToolsLib_v0.1.jar')
compile files('gradle/wrapper/gradle-wrapper.jar')
}
依赖{ 编译com.google.firebase:firebase-messaging:10.0.1' }
应用插件:' com.google.gms.google-services'
build.grdle proj :
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.7' // 1.8?
classpath 'com.google.gms:google-services:9.0.0'
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
错误:
Error:Could not find com.google.gms:google-services:9.0.0.
Searched in the following locations:
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/google/gms/google-services/9.0.0/google-services-9.0.0.pom
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/google/gms/google-services/9.0.0/google-services-9.0.0.jar
https://jcenter.bintray.com/com/google/gms/google-services/9.0.0/google-services-9.0.0.pom
https://jcenter.bintray.com/com/google/gms/google-services/9.0.0/google-services-9.0.0.jar
https://repo1.maven.org/maven2/com/google/gms/google-services/9.0.0/google-services-9.0.0.pom
https://repo1.maven.org/maven2/com/google/gms/google-services/9.0.0/google-services-9.0.0.jar
Required by:
project :
答案 0 :(得分:1)
最后google-services
版本为3.1.0
,因此请按如下方式修改 build.gradle项目文件:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.1.0'
...
}
}
然后,在 build.gradle app 文件中,您可以使用com.google.gms:google-services:9.0.0
,但我认为,实际上最后一个版本是11.0.2
,因此我建议您使用更新
答案 1 :(得分:0)
https://firebase.google.com/docs/android/setup https://firebase.google.com/docs/android/setup#manually_add_firebase
您的app / build.gradle的依赖项看起来不错,但要确保在根底有apply plugin: 'com.google.gms.google-services'
。
您的project / build.gradle没有。来自docs:
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:3.1.0'
}
}
为什么你有额外的classpath 'com.google.gms:google-services:9.0.0'
?
请根据文档查看并仔细检查您的设置。