我有一个奇怪的问题。将Google Play服务库从版本10.2.6上传到版本11.0.0后,当我尝试编译时出现此错误:
错误:任务':app:processDebugGoogleServices'的执行失败。 请修改版本冲突,方法是更新google-services插件的版本(https://bintray.com/android/android-tools/com.google.gms.google-services/提供有关最新版本的信息)或将com.google.android.gms版本更新为11.0.0。
我访问了错误中提到的链接,google-services插件的最新版本似乎是3.1.0,即我正在使用的版本,我已经将所有播放服务库升级到11.0.0版本。如何使用11.0.0版本的GMS编译我的代码?
这是我的build.gradle文件(模块范围):
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.app"
minSdkVersion 15
targetSdkVersion 25
versionCode 23
versionName "0.7.3.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
manifestPlaceholders = [onesignal_app_id : "12345678-1234-1234-1234-123456789",
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: "REMOTE"]
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
prontopro {
applicationId "com.example.app"
buildConfigField "boolean", "TEST_ENVIRONMENT", "false"
}
prontoproTest {
applicationId "com.example.app"
buildConfigField "boolean", "TEST_ENVIRONMENT", "true"
}
}
dataBinding {
enabled = true
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.google.android.gms:play-services-places:11.0.0'
compile 'com.google.android.gms:play-services-location:11.0.0'
compile 'org.parceler:parceler-api:1.1.6'
annotationProcessor 'org.parceler:parceler:1.1.6'
annotationProcessor 'com.android.databinding:compiler:2.2.2'
compile 'com.viewpagerindicator:library:2.4.1'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.4.2'
compile 'com.google.code.gson:gson:2.7'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.github.chrisbanes:PhotoView:1.2.6'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'io.realm:android-adapters:2.0.0'
compile 'com.google.firebase:firebase-crash:10.2.6'
//reactive libraries
compile 'io.reactivex:rxandroid:1.2.1'
compile 'io.reactivex:rxjava:1.2.3'
compile 'com.jakewharton.rxbinding:rxbinding:1.0.0'
compile 'com.jakewharton.rxbinding:rxbinding-support-v4:1.0.0'
compile 'com.jakewharton.rxbinding:rxbinding-appcompat-v7:1.0.0'
compile 'com.jakewharton.rxbinding:rxbinding-design:1.0.0'
compile 'com.jakewharton.rxbinding:rxbinding-recyclerview-v7:1.0.0'
compile 'com.tbruyelle.rxpermissions:rxpermissions:0.8.2@aar'
compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
compile 'com.github.pwittchen:reactivenetwork:0.8.0'
compile 'com.hwangjr.rxbus:rxbus:1.0.5'
compile 'com.f2prateek.rx.preferences:rx-preferences:1.0.2'
//testing
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:2.6.3'
//onesignal
compile 'com.onesignal:OneSignal:3.4.4@aar'
compile "com.mixpanel.android:mixpanel-android:5.1.0"
compile 'com.google.android.gms:play-services-gcm:11.0.0'
}
apply plugin: 'com.google.gms.google-services'
最后这是我的build.gradle文件(app scope):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'io.realm:realm-gradle-plugin:3.1.4'
classpath 'com.google.gms:google-services:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url "http://dl.bintray.com/populov/maven" }
maven { url "https://jitpack.io" }
mavenCentral()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
答案 0 :(得分:24)
您应该删除行apply plugin: 'com.google.gms.google-services'
因为apply plugin: 'com.android.application'
已经有相同的包。
这就是冲突发生的地方。
更新:
使用Play服务版11.0.1
答案 1 :(得分:5)
使用播放服务版本12.0.0
和
在项目级gradle中使用classpath 'com.google.gms:google-services:3.1.0'
编辑答案已更新至最新版本
答案 2 :(得分:1)
在Android Studio重大更新后,清理重建项目。更好您可以使用版本10.
答案 3 :(得分:1)
您可能已经准备好解决了这个问题,但是将Firebase插件更新到11.0.1也为我解决了问题。
答案 4 :(得分:1)
对我有用的是以下
Project Gradle
import sqlalchemy
from sshtunnel import SSHTunnelForwarder
with SSHTunnelForwarder(
"C_ssh_shortcut", # The SSHTunnelForwarder "ssh_address_or_host" argument, which takes care of bypassing B through the ProxyCommand set up in ~/.ssh/config
remote_bind_address=(D_host, 3306), # Points to your desired destination, ie. database host on 3306, which is the MySQL port
local_bind_address=('', 1111) # Gives a local way to access this host and port on your machine. '' is localhost / 127.0.0.1, 1111 is an unused port
) as server:
connection_string = "mysql+pymysql://D_user:D_password@localhost:1111/D_dbname" # note that D_host and D_port were replaced by the host and port defined in "local_bind_address"
engine = sqlalchemy.create_engine(connection_string)
# do your thing
App Gradle
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'com.google.gms:google-services:3.0.0'
依赖
compileSdkVersion 26
buildToolsVersion '26.0.0'
defaultConfig {
minSdkVersion 16
targetSdkVersion 26
multiDexEnabled = true
}
答案 5 :(得分:0)
尝试直接定位所需的服务,例如,如果您想获得SmsRetriver编译
compile 'com.google.android.gms:play-services-auth-api-phone:11.0.1'
而不是
compile 'com.google.android.gms:play-services:11.0.1'