在我的一个项目中,我需要使用GoogleMaps
和Firebase
进行通知,但服务库和Firebase不希望工作。
buildscript {
repositories {
google()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.google.android.gms:play-services:8.4.0'
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
allprojects {
repositories {
jcenter()
}
}
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url "https://maven.google.com" }
}
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.online.app"
minSdkVersion 16
targetSdkVersion 25
versionCode 8
versionName "2.5"
multiDexEnabled true
}
buildTypes {
release {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-v4:26.0.2'
compile 'me.leolin:ShortcutBadger:1.1.6@aar'
compile('com.crashlytics.sdk.android:crashlytics:2.6.0@aar') {
transitive = true;
}
compile "com.google.firebase:firebase-ads:11.8.0"
compile "com.android.support:appcompat-v7:26.1.0"
compile 'com.android.support:multidex:1.0.1'
}
apply plugin: 'com.google.android.gms:play-services'
错误:
Gradle sync failed: Plugin with id 'com.google.android.gms:play-services' not found.
Consult IDE log for more details (Help | Show Log) (2s 325ms)
答案 0 :(得分:5)
改变这个:
apply plugin: 'com.google.android.gms:play-services'
到此:
apply plugin: 'com.google.gms.google-services'
查看此信息以获取更多信息:https://developers.google.com/android/guides/google-services-plugin
答案 1 :(得分:1)
您有2个错误:
在buildscript
阻止中使用正确的插件:
dependencies {
classpath 'com.google.gms:google-services:3.1.1'
// ...
}
而不是classpath 'com.google.android.gms:play-services:8.4.0'
然后在底部您还更改插件的名称:
apply plugin: 'com.google.gms.google-services'
而不是:
apply plugin: 'com.google.android.gms:play-services'
也不要使用2个 buildscript
块。
只需删除此块,并在上一个块中添加存储库和插件:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
答案 2 :(得分:0)
您需要使用
apply plugin: 'com.google.gms.google-services'