错误快速登录

时间:2018-05-25 18:16:45

标签: android android-studio

我的申请已停止,请勿打开。

我无法解决。

我正在尝试使用我的应用程序登录,但我不能。我尝试了firebase和现在的QuickBox,但我不能,应用程序没有打开,并给出错误。有人能帮我吗?我很绝望。

我不明白错误的原因。我的朋友在他的应用程序上做了它并且工作。我希望尽快解决......

public class ScreenLogin extends AppCompatActivity  {

private RelativeLayout rellay1, rellay2;

static final String APP_ID = "71";
static final String AUTH_KEY = "NU;
static final String AUTH_SECRET = "kReC";
static final String ACCOUNT_KEY = "ceSuE";

private Button buttonLogin, buttonCadastro;
private EditText editTextSenha, editTextUsuario;




Handler handler = new Handler();
Runnable runnable = new Runnable() {
    @Override
    public void run() {
        rellay1.setVisibility(View.VISIBLE);
        rellay2.setVisibility(View.VISIBLE);
    }
};


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

    iniatilizeFramework();

    rellay1 = (RelativeLayout) findViewById(R.id.rellay1);
    rellay2 = (RelativeLayout) findViewById(R.id.rellay2);

    handler.postDelayed(runnable, 2000); //2000 é o tempo

    buttonLogin = (Button) findViewById(R.id.btn_login);
    buttonCadastro = (Button) findViewById(R.id.buttonRegistro);

    editTextUsuario = (EditText) findViewById(R.id.editTextUsuarioLogin);
    editTextSenha = (EditText) findViewById(R.id.editTextSenha1);

    buttonCadastro.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(ScreenLogin.this, ScreenRegister.class));
        }
    });

    buttonLogin.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String usuario = editTextUsuario.getText().toString();
            String senha = editTextSenha.getText().toString();

            QBUser qbUser = new QBUser(usuario,senha);

            QBUsers.signIn(qbUser).performAsync(new QBEntityCallback<QBUser>() {
                @Override
                public void onSuccess(QBUser qbUser, Bundle bundle) {
                    Toast.makeText(getBaseContext(), "Logado com sucesso!", Toast.LENGTH_LONG).show();
                    Intent intent = new Intent(ScreenLogin.this, ScreenFeed.class);
                    startActivity(intent);
                }

                @Override
                public void onError(QBResponseException e) {
                    Toast.makeText(getBaseContext(), ""+e.getMessage(), Toast.LENGTH_LONG).show();
                }
            });

        }
    });

}

private void iniatilizeFramework() {
    QBSettings.getInstance().init(getApplicationContext(), APP_ID, AUTH_KEY, AUTH_SECRET);
    QBSettings.getInstance().setAccountKey(ACCOUNT_KEY);
}

}

登录课程!

错误:

05-25 15:02:07.898 23075-23075/com.example.hankmoody.sridioma E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.hankmoody.sridioma, PID: 23075
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.hankmoody.sridioma/com.example.hankmoody.sridioma.ScreenLogin}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2678)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2743)
    at android.app.ActivityThread.-wrap12(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1490)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6165)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:778)
 Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
    at com.example.hankmoody.sridioma.ScreenLogin.onCreate(ScreenLogin.java:66)
    at android.app.Activity.performCreate(Activity.java:6687)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1140)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2631)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2743) 
    at android.app.ActivityThread.-wrap12(ActivityThread.java) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1490) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:154) 
    at android.app.ActivityThread.main(ActivityThread.java:6165) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:778) 

1 个答案:

答案 0 :(得分:0)

可能activity_screen_login.xmlsetContentView设置按钮的ID似乎被错误引用。

检查activity_screen_login.xml中声明的按钮的ID。

有时它似乎在Android studio中被正确引用。

Clean项目构建。或者尝试删除项目构建文件夹并重建。