【发布时间】:2016-10-15 02:23:43
【问题描述】:
我正在尝试学习 Firebase,所以我通过了 Android Codelab。然而,他们给我的项目有一个错误:
无法解析符号 default_web_client_id
而且我不知道如何解决它,因为我不知道default_web_client_id 的值或它是什么。它在onCreate() 方法中:
SigninActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_in);
mFirebaseAuth = FirebaseAuth.getInstance();
// Assign fields
mSignInButton = (SignInButton) findViewById(R.id.sign_in_button);
// Set click listeners
mSignInButton.setOnClickListener(this);
// Configure Google Sign In
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.default_web_client_id))
.requestEmail()
.build();
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
}
我不知道它是什么,它的价值是什么,以及为什么它会给我这个错误。到目前为止,除了添加google-services.json 之外,我没有更改任何内容。我已经添加了我的SHA-1 并在控制台中启用了 Google。
【问题讨论】:
-
您必须从 developer.google.com 注册到 Auth 2.0。使用这个:console.developers.google.com/apis/credentials?project=_ 生成 Auth 2.0 密钥
-
@M.WaqasPervez 我已经添加了我的 SHA1 密钥,Auth2.0 有什么不同吗?
-
您能否确保您的
app/build.gradle底部有这行apply plugin: 'com.google.gms.google-services',如文档中的here 所述?
标签: android firebase cannot-find-symbol