我的代码中FirebaseAuth.getInstance的返回值为空,这导致我的应用无法运行。这是我的主要资料:
public class MainActivity extends AppCompatActivity {
//Firebase Auth
public static final int RC_SIGN_IN = 1;
//Cloud vision
private static final String CLOUD_VISION_API_KEY = "AIzaSyBHgLORJOy0BAp6PYL5DqX0hwQYAv8-3xE";
public static final String FILE_NAME = "temp.jpg";
private static final String ANDROID_CERT_HEADER = "X-Android-Cert";
private static final String ANDROID_PACKAGE_HEADER = "X-Android-Package";
//Cloud vision
private static final String TAG = MainActivity.class.getSimpleName();
private static final int GALLERY_PERMISSIONS_REQUEST = 0;
private static final int GALLERY_IMAGE_REQUEST = 1;
public static final int CAMERA_PERMISSIONS_REQUEST = 2;
public static final int CAMERA_IMAGE_REQUEST = 3;
//Cloud vision
private TextView mImageDetails;
private ImageView mMainImage;
//Firebase instance variables
//DATABASE
/*
private FirebaseDatabase mFirebaseDatabase;
private DatabaseReference mPhotosDatabaseReference;
private DatabaseReference mVisionOutputDatabaseReference;
private DatabaseReference mUserFeedbackDatabaseReference;
*/
//AUTH
private FirebaseAuth mFirebaseAuth;
private FirebaseAuth.AuthStateListener mAuthStateListener;
//Cloud vision
@Override
protected void onCreate(Bundle savedInstanceState) {
//Cloud vision
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Initialize Firebase
//Database
//mFirebaseDatabase = FirebaseDatabase.getInstance();
//Auth
mFirebaseAuth = FirebaseAuth.getInstance();
最后一行是我得到零回报的地方。
干杯。
最佳答案
如果没有互联网连接,则可以输入null。如果连接速度较慢,则可能无法立即使用。
关于android - FirebaseAuth为空,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/43188120/