Ответ 1
Обнаружено, что проблема устранена.
Обновите свой путь к классу на уровне проекта gradle com.google.gms:google-services:2.1.0
до пути к классу com.google.gms:google-services:3.0.0
Я обновил файл build.gradle с
compile 'com.google.android.gms:play-services:8.4.0'
к
compile 'com.google.android.gms:play-services:9.0.0'
и теперь я получаю эту ошибку, которую я раньше не делал.
Ошибка: не удалось выполнить: com.google.android.gms: play-services-measurement: 9.0.0
Обнаружено, что проблема устранена.
Обновите свой путь к классу на уровне проекта gradle com.google.gms:google-services:2.1.0
до пути к классу com.google.gms:google-services:3.0.0
Требуется: последние версии Android Studio и сервисов Google Play
Вы можете добавить плагин в свой проект, обновив файлы build.gradle верхнего уровня и файлы на уровне приложения на уровне приложения следующим образом:
classpath 'com.google.gms:google-services:3.0.0'
Как
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenLocal()
}
}
Теперь вам нужно добавить зависимость для сервисов Google Play. Внутри приложения build.gradle добавьте:
compile 'com.google.android.gms:play-services:9.6.1'
Наконец
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "// set Yours"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'LICENSE.txt'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services-gcm:9.6.1'
compile 'com.android.support:appcompat-v7:24.2.0'
}
apply plugin: 'com.google.gms.google-services'
GCM был rebranded
до Firebase
Cloud Messaging (FCM), если вы хотите использовать com.google.android.gms:play-services:9.0.0
, прочитайте эту статью FCM,
Возможно, это работает, измените ваш файл build.gradle
, чтобы использовать плагин.
buildscript {
dependencies {
// Add this line
classpath 'com.google.gms:google-services:3.0.0'
}
}
Самый простой способ - использовать последнюю версию для всех.
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'
})
//apply plugin: 'com.google.gms.google-services' //Firebase
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha8'
compile 'com.google.firebase:firebase-auth:10.2.6'
compile 'com.google.android.gms:play-services-auth:10.2.6' //10.2.6
compile 'com.google.firebase:firebase-core:10.2.6' // used for FCM
compile 'com.google.firebase:firebase-messaging:10.2.6' // used for FCM
testCompile 'junit:junit:4.12'
// apply plugin: 'com.google.gms.google-services'
}
Explaination
применить плагин: 'com.google.gms.google-services'//Добавить это внизу.
apply plugin: 'com.google.gms.google-services'
//Добавьте это внизу.Затем добавьте их в зависимости
compile 'com.google.firebase:firebase-auth:10.2.6'
//make suere это последняя версия.
compile 'com.google.android.gms:play-services-auth:10.2.6'
//10.2.6 Последние
compile 'com.google.firebase:firebase-core:10.2.6'
//используется для FCM
compile 'com.google.firebase:firebase-messaging:10.2.6'
//используется для FCM
Предположим, что у вас есть firebase-auth 10.2.6, который является последним сегодня 25 мая 2017 года. Но одновременно вы используете play-services-auth: 9.0.0 или ниже, чем последние, тогда оба они не могут сделать и покажите вам ошибку.
Я надеюсь, что это помогло.
Я решил эту сложную проблему, изменив строку в Gradle на
compile 'com.google.android.gms:play-services:9.0.0' //or latest version
При изменении сервисов воспроизведения к версии выше 10.2.1 мои зависимости начали отказываться.
Я узнал, что изменение следующего URL-адреса maven решило проблему:
maven { url 'https://raw.githubusercontent.com/onepf/OPF-mvn-repo/master/' }
к
maven { url 'https://github.com/onepf/OPF-mvn-repo/raw/master/' }
Возможно, что изменение URL-адресов избегает кэширования в gradle или maven, и это разрешает его.