输入字母进行注册/登录活动时,我的应用程序崩溃

时间:2018-11-28 19:19:59

标签: android

我遇到问题,无法调试。 当我尝试登录或注册时,应用程序崩溃。 当仅添加一个字母时,我会收到消息“我的应用程序”不断停止。

我的登录/注册活动没有任何问题,我无法调试它,因为应用程序的第一个字母崩溃了。

感谢您的帮助。

这是“登录”活动,例如:

import android.content.Intent;
import android.support.design.widget.TextInputLayout;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
/**
 * Login
 * This class for login
 * Check if the input is admin and send to another activity
 */
public class Login extends AppCompatActivity {

    DatabaseHelper helper = new DatabaseHelper(this);
    private TextInputLayout textInputPassword;
    private TextInputLayout textInputUsername;

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

        textInputUsername = findViewById(R.id.etUserName);
        textInputPassword = findViewById(R.id.etPassword);

        TextView tvjuinUs = (TextView) findViewById(R.id.tvJuinUs);

        //Check if user already exist pass move to login
        tvjuinUs.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(Login.this, JoinUs.class);
                startActivity(intent);
                finish();
            }
        });
    }


    //Check if user name & password exist in database
    public void CheckDetails(View v) {
        String username = textInputUsername.getEditText().getText().toString().trim();
        String pass = textInputPassword.getEditText().getText().toString().trim();

        try {
            if ((username.equals("admin")) && (pass.equals("admin"))) {
                Intent intent = new Intent(Login.this, AdminConnection.class);
                startActivity(intent);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        //Check match beetwen user name and pass
        if (!(helper.checkMatcForUser(username, pass))) {
            Toast.makeText(getApplicationContext(), "Login Failed. The email or password you entered is incorrect", Toast.LENGTH_LONG).show();
            textInputUsername.setError("ERROR !!!");
            textInputPassword.setError("ERROR !!!");
            return;
        }
        if ((helper.searchUsername(username)) && (helper.searchPassword(pass))) {

        } else {
            textInputUsername.setError("User or Password don't match!");
            textInputPassword.setError("Password or user don't match!");

        }
    }


}

这是错误:

E/InputEventSender: Exception dispatching finished signal.
E/MessageQueue-JNI: Exception in MessageQueue callback: 
 handleReceiveCallback
E/MessageQueue-JNI: java.lang.NoSuchMethodError: No static method 
dispatchUnhandledKeyEventPre(Landroid/view/View;Landroid/view/KeyEvent;)Z in class Landroid/support/v4/view/ViewCompat; or its super classes (declaration of 'android.support.v4.view.ViewCompat' appears in /data/app/com.example.aviorka.bstrong-ZZzNIVOJeVtP54s_AGokUw==/base.apk)
                    at android.support.v7.app.AppCompatDelegateImpl.dispatchKeyEvent(AppCompatDelegateImpl.java:1162)
                    at android.support.v7.app.AppCompatDelegateImpl$AppCompatWindowCallback.dispatchKeyEvent(AppCompatDelegateImpl.java:2529)
                    at com.android.internal.policy.DecorView.dispatchKeyEvent(DecorView.java:342)
                    at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4991)
                    at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4856)
                    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4377)
                    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4430)
                    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4396)
                    at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4536)
                    at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4404)
                    at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4593)
                    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4377)
                    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4430)
                    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4396)
                    at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4404)
                    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4377)
                    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4430)
                    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4396)
                    at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4569)
                    at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:4730)
                    at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:2559)
                    at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:2069)
                    at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:2060)
                    at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:2536)
                    at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:141)
                    at android.os.MessageQueue.nativePollOnce(Native Method)
                    at android.os.MessageQueue.next(MessageQueue.java:326)
                    at android.os.Looper.loop(Looper.java:160)
                    at android.app.ActivityThread.main(ActivityThread.java:6642)
                    at java.lang.reflect.Method.invoke(Native Method)
                    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
              Process: com.example.aviorka.bstrong, PID: 8924
              java.lang.NoSuchMethodError: No static method 
dispatchUnhandledKeyEventPre(Landroid/view/View;Landroid/view/KeyEvent;)Z in class Landroid/support/v4/view/ViewCompat; or its super classes (declaration of 'android.support.v4.view.ViewCompat' appears in /data/app/com.example.aviorka.bstrong-ZZzNIVOJeVtP54s_AGokUw==/base.apk)
                  at android.support.v7.app.AppCompatDelegateImpl.dispatchKeyEvent(AppCompatDelegateImpl.java:1162)
                  at android.support.v7.app.AppCompatDelegateImpl$AppCompatWindowCallback.dispatchKeyEvent(AppCompatDelegateImpl.java:2529)
                  at com.android.internal.policy.DecorView.dispatchKeyEvent(DecorView.java:342)
                  at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4991)
                  at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4856)
                  at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4377)
                  at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4430)
                  at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4396)
                  at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4536)
                  at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4404)
                  at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4593)
                  at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4377)
                  at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4430)
                  at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4396)
                  at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4404)
                  at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4377)
                  at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4430)
                  at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4396)
                  at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4569)
                  at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:4730)
                  at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:2559)
                  at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:2069)
                  at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:2060)
                  at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:2536)
                  at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:141)
                  at android.os.MessageQueue.nativePollOnce(Native Method)
                  at android.os.MessageQueue.next(MessageQueue.java:326)
                  at android.os.Looper.loop(Looper.java:160)
                  at android.app.ActivityThread.main(ActivityThread.java:6642)
                  at java.lang.reflect.Method.invoke(Native Method)
                  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
                  at 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I/Process: Sending signal. PID: 8924 SIG: 9
Disconnected from the target VM, address: 'localhost:8600', transport: 
'socket'

//此支持库:build.gradle(Module:app)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.aviorka.bstrong"
        minSdkVersion 28 
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
    implementation 'com.android.support:cardview-v7:28.0.0-alpha3'
    implementation 'com.android.support:design:28.0.0-alpha3'
    implementation 'com.thoughtbot:expandablerecyclerview:1.3'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:support-v4:28.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

3 个答案:

答案 0 :(得分:0)

更新支持库,它将得到修复。

答案 1 :(得分:0)

28.0.0的稳定版本现已发布。请使用

28.0.0

版本而不是

28.0.0-alpha3

并立即设置minSdkVersion 21 (Android L)。因为您设置了minSdkVersion 28 (Android P),这意味着它仅适用于Android 9设备。

答案 2 :(得分:0)

我从应用程序gradle更新到28.0.0,而不是28.0.0-alpha3。 并设置minSDKversion 21。

问题解决了!