在Android Studio中获取错误“无法解析符号FirebaseAuth”
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import com.google.firebase.auth.FirebaseAuth;
public class MainActivity extends AppCompatActivity {
FirebaseAuth firebaseAuth;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
firebaseAuth.FirebaseAuth.getInstance();
}
}
我添加并同步了以下依赖项
compile 'com.google.firebase:firebase-core:11.8.0'
compile 'com.google.firebase:firebase-auth:11.8.0'
compile "com.google.android.gms:play-services-gcm:11.8.0"
创建FirebaseAuth变量没有错误。在我清理了项目之后,我仍然在这一行收到错误:
firebaseAuth.FirebaseAuth.getInstance();
答案 0 :(得分:1)
这不应该是这样的
firebaseAuth.FirebaseAuth.getInstance();
应该是这样的
firebaseAuth = FirebaseAuth.getInstance();
完整代码:
public class MainActivity extends AppCompatActivity {
FirebaseAuth firebaseAuth;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
firebaseAuth = FirebaseAuth.getInstance();
}
}