java - 无法解析符号 'default_web_client_id' 错误,但应用程序运行成功

标签 java android firebase firebase-authentication cannot-find-symbol

Screenshot Image

我已尝试删除并重新导入新的 google-service.json 文件。如您所见,Build 和 Logcat 中没有错误,构建后 App 中也没有任何问题。

但是红线显示在下面

default_web_client_id

作为

Cannot resolve symbol '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'

注意:依赖的版本可能会改变

2.重建你的项目

Build ---> Rebuild

关于java - 无法解析符号 'default_web_client_id' 错误,但应用程序运行成功,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54429715/

相关文章:

android - AlarmManager 以不一致的方式发送带有旧数据的未决 Intent

java - 最佳实践 : Design pattern for 2D HUD screen navigation

android - <div> 在 android 中发送电子邮件时不创建列

javascript - 如何在 firestore 中插入和自动删除不必要的或空的

java - Java 中的 VTD-XML - 在 XMLModifier.insertAfterElement 之后查找索引

java - 什么时候在 Java 中使用 flush()?

JavaFX 网络支持(TCP、UDP、SSH)?

java - WildFly - 创建具有长时间运行的应用程序的应用程序

javascript - 在推送中访问 firebase 数据 id

reactjs - Next.js Typescript 上的 Firebase Auth 错误/参数错误