Cannot resolve symbol default_web_client_id in Firebase's Android Codelab

前端 未结 19 1334
说谎
说谎 2021-02-01 05:18

I am trying to learn Firebase, so I went through the Android Codelab. The project they gave me however, had an error:

Cannot resolve symbol default_web_cl

相关标签:
19条回答
  • 2021-02-01 06:05

    Generic solution for this is to apply google play services plugin at the end of build.gradle like this

      apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 30
        buildToolsVersion "30.0.0"
    
        buildFeatures {
            dataBinding true
        }
    
        defaultConfig {
            applicationId "xxxxxx"
            minSdkVersion 21
            targetSdkVersion 30
            versionCode 1
            versionName "1.0"
            multiDexEnabled true
            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        }
    
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            }
        }
    }
    
    dependencies {
        implementation fileTree(dir: "libs", include: ["*.jar"])
        implementation 'androidx.appcompat:appcompat:1.2.0'
        implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    
    
    
        testImplementation 'junit:junit:4.13'
        androidTestImplementation 'androidx.test.ext:junit:1.1.1'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
        // For Common Dimension
        implementation 'com.intuit.sdp:sdp-android:1.0.5'
        implementation 'com.intuit.ssp:ssp-android:1.0.5'
        // Retrofit and Gson
        implementation 'com.google.code.gson:gson:2.8.6'
        implementation 'com.squareup.retrofit2:retrofit:2.6.1'
        implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
        implementation 'com.squareup.retrofit2:converter-scalars:2.6.1'
        // Rx Java and Dagger
        implementation 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
        implementation 'io.reactivex:rxandroid:1.2.1'
        implementation 'io.reactivex:rxjava:1.1.6'
    
        implementation 'com.google.dagger:dagger:2.24'
        annotationProcessor 'com.google.dagger:dagger-compiler:2.24'
        compileOnly 'javax.annotation:jsr250-api:1.0'
        compileOnly 'org.glassfish:javax.annotation:10.0-b28'
        // Glide Image Loading
        implementation 'com.github.bumptech.glide:glide:4.9.0'
        annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
        implementation 'com.android.support:design:30.0.0'
        implementation 'com.android.support:recyclerview-v7:30.0.0'
        implementation 'com.android.support:cardview-v7:30.0.0'
        implementation 'com.android.support:multidex:1.0.3'
    
        /*Jsoup*/
        implementation 'org.jsoup:jsoup:1.9.1'
    
        /*Firebase*/
        implementation 'com.google.firebase:firebase-core:17.5.0'
        implementation 'com.google.firebase:firebase-config:19.2.0'
        implementation 'com.google.firebase:firebase-messaging:20.2.4'
        implementation 'com.google.firebase:firebase-database:19.3.1'
        implementation 'com.google.firebase:firebase-auth:19.3.2'
        implementation 'com.firebaseui:firebase-ui-storage:6.2.0'
        implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
        implementation 'com.google.firebase:firebase-analytics:17.5.0'
    
        /*location and google map*/
        implementation 'com.google.android.gms:play-services-maps:17.0.0'
        implementation 'com.google.android.gms:play-services-location:17.0.0'
        implementation 'com.google.android.gms:play-services-places:17.0.0'
        implementation 'com.google.android.gms:play-services-auth:18.1.0'
    
        /*Circle Image View*/
        implementation 'de.hdodenhof:circleimageview:3.0.1'
        implementation 'com.github.ittianyu:BottomNavigationViewEx:2.0.4'
        implementation "com.android.support:design:30.0.0"
        implementation 'com.facebook.android:facebook-android-sdk:5.15.3'
    
    }
    
    apply plugin: 'com.google.gms.google-services'
    
    0 讨论(0)
  • 2021-02-01 06:06

    I had the same problem or similar,

    Make sure that in your google-services.json you have:

    ...    
    "client": [
            ...
              "oauth_client": [
                ...
                {
                  "client_id": "YOUR WEB CLIENT ID",
                  "client_type": 3
                }     
    ...
    

    For some reason the file downloaded from firebase console doesn't include it.

    After adding the entry in the google-services.json file, everything started working as expected.

    google-services-plugin documentation

    0 讨论(0)
  • 2021-02-01 06:09

    Try downloading your .json file again after changing the configuration in the Firebase console. Use this newer configuration file, not the old one.

    0 讨论(0)
  • 2021-02-01 06:09

    For me the problem was because I was using minSdkVersion 15, updating to 16 has solved my problem.

    0 讨论(0)
  • 2021-02-01 06:10

    Sometimes there is issue while parsing google-services.json. I have reported this issue with to concerned team.

    Meanwhile follow below step to fix this issue to get going further -

    1) Open google-services.json file -> client -> oauth_client -> client_id

    2) Copy this client ID and hardcode this .requestIdToken("your ID")

    It would allow to request "IdToken" via GoogleSignInAccount post successful google login and to authorize your credential with firebase.

    EDIT

    Try deleting and recreating the project and re-importing new google-service.jsonin your Android project

    0 讨论(0)
  • 2021-02-01 06:10

    After a time searching the "smart" fix without insert directly the client_id, following this answer from FirebaseUI project I just need to add the next line in app/build.gradle:

    implementation 'com.firebaseui:firebase-ui-auth:4.3.2'
    
    0 讨论(0)
提交回复
热议问题