[英]How does google-services.json replace default_web_client_id?
[英]Cannot resolve symbol 'default_web_client_id' Error , But App Runs Successfully
我已嘗試刪除並重新導入新的 google-service.json 文件。 如您所見, Build 和 Logcat 中沒有錯誤,構建后 App 中也沒有任何問題。
但紅線顯示在下方
default_web_client_id
作為
無法解析符號“default_web_client_id”
嘗試排除各種 META_INF ,遷移到 AndroidX ,生成 SHA 證書指紋和 WebKey 后重新下載 Json 文件,使緩存/重啟無效。
build.graddle(模塊應用)
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "academy.learnprogramming.subjoin"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
packagingOptions
{
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude 'allclasses-frame.html'
exclude 'allclasses-noframe.html'
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '28.0.3'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleCompatible
implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
implementation 'com.google.android.material:material:1.0.0-beta01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
implementation 'com.google.firebase:firebase-auth:16.1.0'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.firebase:firebase-database:16.0.5'
implementation 'com.google.firebase:firebase-storage:16.0.5'
implementation 'de.hdodenhof:circleimageview:3.0.0'
api 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.firebaseui:firebase-ui-database:4.3.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
implementation 'androidx.recyclerview:recyclerview:1.0.0-beta01'
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
}
apply plugin: 'com.google.gms.google-services'
build.graddle(模塊項目)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
重建default_web_client_id 后未獲取並顯示錯誤(但應用程序運行成功)然后
1.在 gradle 中應用給定的依賴項以消除此錯誤:
implementation 'com.firebaseui:firebase-ui-auth:4.3.2'
注意:依賴的版本可能是 Change
2.重建你的項目
Build ---> Rebuild
由於刪除了您的客戶端ID(default_web_client_id)而導致此錯誤
-項目->應用程序->構建->生成-> res->谷歌服務->調試->值-> values.xml
您必須在
android-> app-> res-> values->字符串(類似於FIREBASE控制台)
<string name="default_web_client_id" translatable="false">237047375768-ma9cm63bn9goidlu99jl3fen5f6mieru.apps.googleusercontent.com</string>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.