Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/184.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android studio中带有firebase的Google登录按钮,错误:找不到符号变量default\u web\u client\u id_Android_Firebase_Google Authentication - Fatal编程技术网

android studio中带有firebase的Google登录按钮,错误:找不到符号变量default\u web\u client\u id

android studio中带有firebase的Google登录按钮,错误:找不到符号变量default\u web\u client\u id,android,firebase,google-authentication,Android,Firebase,Google Authentication,我尝试在我的android应用程序中使用谷歌登录按钮(建议使用firebase),如下所示: GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken(getString(R.string.default_web_client_id)) .requestEmail()

我尝试在我的android应用程序中使用谷歌登录按钮(建议使用firebase),如下所示:

        GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken(getString(R.string.default_web_client_id))
            .requestEmail()
            .build();
    // [END config_signin]

    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();
但返回此错误:错误:(112,51)错误:找不到符号变量default\u web\u client\u id


如果我试图修改我的R目录,我不能,所以我被卡住了。在R文件中我的应用程序的早期版本中,我已经
publicstaticfinalintdefault\uweb\uclient\uid=0x7f060079

默认的\u web\u客户端\u id
由google服务插件从Firebase下载的JSON配置生成

确保您已遵循上所述的Firebase Android设置

  • 将Firebase控制台中的
    google services.json
    添加到应用程序/模块目录中
  • 添加到root build.gradle:
    classpath'com.google.gms:google services:3.1.0'
  • 应用程序build.gradle底部的插件:
    Apply plugin:'com.google.gms.google services'

  • 我删除并再次添加了google-services.json,现在错误消失了,谷歌登录不起作用,但至少我没有更多的错误。好的,这是一个好的开始!检查应用程序的SHA1是否已添加到控制台中,这是谷歌登录的常见问题。