2017-05-31 74 views
1

我已經研究了一段時間,沒有找到任何幫助。我幾乎完成了我的應用程序,我希望添加Google登錄功能。我並沒有要求任何人爲我糾正我的代碼。我只需要指出正確的方向。每個網站,包括android開發者網站,都沒有幫助。任何你的幫助表示讚賞。再次,我只需要指出正確的方向,不要爲我寫的代碼。GoogleApiClient for Google登錄

做了什麼答案告訴我,並得到這個錯誤代碼。首先它告訴我改爲10.2.1,然後改爲9.0.0:

錯誤:執行任務':app:processDebugGoogleServices'失敗。

Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 9.0.0.

這是我的搖籃文件:

apply plugin: 'com.android.application' 

android { 
signingConfigs { 
    config { 
     keyAlias 'cm' 
     keyPassword 'cr3101120$$' 
     storeFile file('C:/Users/Carter/AndroidStudioProjects/ColorMatch/release.jks') 
     storePassword 'cr3101120$$' 
    } 
} 
compileSdkVersion 25 
buildToolsVersion "25.0.2" 
defaultConfig { 
    applicationId "carsquared.colormatch" 
    minSdkVersion 19 
    targetSdkVersion 23 
    versionCode 1 
    versionName "1.0" 
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    vectorDrawables.useSupportLibrary = true 
} 
buildTypes { 
    release { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     zipAlignEnabled true 
    } 
    debug { 
     signingConfig signingConfigs.config 
     zipAlignEnabled true 
    } 
} 
productFlavors { 
} 
} 

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' 
compile 'com.android.support:appcompat-v7:25.3.1' 
compile 'com.android.support:support-v4:25.3.1' 
compile 'com.android.support:support-vector-drawable:25.3.1' 
compile 'com.android.support.constraint:constraint-layout:1.0.2' 
compile 'com.google.firebase:firebase-messaging:10.2.6' 
compile 'com.google.android.gms:play-services-auth:10.2.6' 
compile 'com.android.support:design:25.3.1' 
testCompile 'junit:junit:4.12' 

} 
apply plugin: 'com.google.gms.google-services' 

這裏的主要搖籃:

// 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 '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() 
} 
} 

task clean(type: Delete) { 
delete rootProject.buildDir 
} 

回答

1
  1. 請註冊這裏 https://developers.google.com/mobile/add?platform=android&cntapi=signin&cnturl=https:%2F%2Fdevelopers.google.com%2Fidentity%2Fsign-in%2Fandroid%2Fsign-in%3Fconfigured%3Dtrue&cntlbl=Continue%20Adding%20Sign-In

  2. Ç reate應用程序和填充包名稱和SHA1

  3. SHA1從您的系統生成這樣的
    a。生成已簽名的apk。(帶有JKS文件)
    b。打開cmd選擇以下路徑「AndroidSetup \ jre \ bin」
    c。運行此coomand keytool -exportcert -list -v -keystore E:\JKSFile\GoEthno.jks E:\JKSFile\GoEthno.jks = your jks file path
    d.Copy SHA-1和粘貼上面definde地方

  4. 啓用谷歌登錄從上述網址

  5. 生成谷歌服務的JSON
  6. 在Android應用程序文件夾
  7. 將谷歌服務的JSON項目

添加這種依賴關係的依賴

{ // .. compile 'com.google.android.gms:play-services-auth:9.2.1' // glide is added to load the g+ profile image. Ignore if you want compile 'com.github.bumptech.glide:glide:3.7.0' } apply plugin: 'com.google.gms.google-services'

,您可以在這裏 http://www.androidhive.info/2014/02/android-login-with-google-plus-account-1/

+0

看到的代碼休息穀歌標誌添加這種依賴關係 依賴{ // .. 編譯「com.google.android.gms:發揮服務-auth的: 9.2.1' // glide被添加來加載g +個人資料圖片。忽略,如果你想 編譯「com.github.bumptech.glide:滑翔:3.7.0」 } 應用插件:「com.google.gms.google服務」 – MageNative

+0

我做過的一切,我得到這個錯誤碼。首先它告訴我將它更新到10.2.1。所以我做了。然後它告訴我'更新'到9.0.0。以下是錯誤:錯誤:任務':app:processDebugGoogleServices'的執行失敗。 >請修正版本衝突,方法是更新google-services插件的版本(有關最新版本的信息,請訪問https://bintray.com/android/android-tools/com.google.gms.google-services /)或將com.google.android.gms的版本更新爲9.0.0。 –

+0

讓我看看你的項目gradle文件 – MageNative