错误:程序包android.support.v7.app不再存在

时间:2019-11-29 11:53:25

标签: java android

我正在尝试遵循此方法。 https://www.youtube.com/watch?v=V0ZrnL-i77Q&t=1976s 发生错误,表示程序包不存在。我遇到了这个问题,我不知道如何安装Android支持库。它不会显示在Android SDK Manager中。 我是Android Studio的新手。请帮我。 这是主要的活动代码。

package sxc.edu.loginpage;

导入Android软件包

import android.content.Intent;
    import android.support.annotation.NonNull;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.TextView;
    import android.widget.Toast;

    import com.google.android.gms.tasks.OnCompleteListener;
    import com.google.android.gms.tasks.Task;
    import com.google.firebase.auth.AuthResult;
    import com.google.firebase.auth.FirebaseAuth;

声明登录页面变量

public class  MainActivity extends AppCompatActivity {
            EditText emailId, password;
            Button btnSignUp;
            TextView tvSignIn;
            FirebaseAuth mFirebaseAuth;


            @Override
            protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.activity_main);

使用Firebase进行登录后端

 mFirebaseAuth = FirebaseAuth.getInstance();
                emailId = findViewById(R.id.editText);
                password = findViewById(R.id.editText2);
                btnSignUp = findViewById(R.id.button2);
                tvSignIn = findViewById(R.id.textView);
                btnSignUp.setOnClickListener(new View.OnClickListener()

然后如果条件检查电子邮件和密码是否为空

{
                    @Override
                    public void onClick(View v) {
                        String email = emailId.getText().toString();
                        String pwd = password.getText().toString();
                        if(email.isEmpty()){
                            emailId.setError("Please enter email id");
                            emailId.requestFocus();
                        }
                        else  if(pwd.isEmpty()){
                            password.setError("Please enter your password");
                            password.requestFocus();
                        }
                        else  if(email.isEmpty() && pwd.isEmpty()){
                            Toast.makeText(MainActivity.this,"Fields Are Empty!",Toast.LENGTH_SHORT).show();
                        }
                        else  if(!(email.isEmpty() && pwd.isEmpty())){
                            mFirebaseAuth.createUserWithEmailAndPassword(email, pwd).addOnCompleteListener(MainActivity.this, new OnCompleteListener<AuthResult>() {
                                @Override
                                public void onComplete(@NonNull Task<AuthResult> task) {
                                    if(!task.isSuccessful()){
                                        Toast.makeText(MainActivity.this,"SignUp Unsuccessful, Please Try Again",Toast.LENGTH_SHORT).show();
                                    }
                                    else {
                                        startActivity(new Intent(MainActivity.this,HomeActivity.class));
                                    }
                                }
                            });
                        }
                        else{
                            Toast.makeText(MainActivity.this,"Error Occurred!",Toast.LENGTH_SHORT).show();

                        }
                    }
                });

                tvSignIn.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent i = new Intent(MainActivity.this,LoginActivity.class);
                        startActivity(i);
                    }
                });
            }
        }

0 个答案:

没有答案