[英]Cannot resolve symbol default_web_client_id GoogleSignInOptions Android Firebase
[英]Android: Cannot resolve symbol GoogleSignInOptions
這是onCreate
函數中的代碼:
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(
GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.build();
這是我的build.gradle(項目級別)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
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
}
這是我的build.gradle(應用程序級別)
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "ca.uoguelph.socs.cis3760.s2_g6"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:design:25.1.1'
compile 'com.android.support:support-v4:25.1.1'
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services-appindexing:9.8.0'
}
apply plugin: 'com.google.gms.google-services'
我真的不知道怎么回事。 先感謝您。
原來我要做的就是導入com.google.android.gms.auth.api.signin.GoogleSignInOptions
!
根據您的buildToolsVersion,您需要使用該庫的正確版本來配置build.gradle(Module:APP)腳本。 假設您的buildToolsVersion為25.3.1,那么您將需要'com.google.android.gms:play-services-auth:11.0.1'
但是, 獲得Google身份驗證服務/登錄Android應用程序的最佳方法之一是遵循以下官方文檔: https : //developers.google.com/identity/sign-in/android/start-integrating
您需要在項目中包括最新的'com.google.android.gms:play-services-auth'
依賴項。 GoogleSignInOptions
是com.google.android.gms.auth.api.signin
包的一部分。
只是為了記錄問題。 發生版本沖突時,會發生這種情況。 檢查構建消息,它將提示您應該導入的版本。 主gradle中的classpath版本( classpath 'com.google.gms:google-services:3.1.0'
)應與應用gradle中包含的jar版本一起投訴( compile 'com.google.android.gms:play-services-auth:11.0.0'
play- compile 'com.google.android.gms:play-services-auth:11.0.0'
)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.