gpt4 book ai didi

java - 在 android studio 中编译应用程序时运行时错误

转载 作者:行者123 更新时间:2023-12-02 12:40:12 26 4
gpt4 key购买 nike

当我运行此应用程序时,模拟器显示该应用程序未运行,并且出现运行时错误

这是我的主要 Activity

package com.mobility.mobilityindia;

import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.design.widget.Snackbar;
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.RelativeLayout;
import android.widget.TextView;

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 implements View.OnClickListener {

Button btnLogin;
EditText input_email,input_password;
TextView btnSignup,btnForgotPass;

RelativeLayout activity_main;
private FirebaseAuth auth;


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

//view
btnLogin=(Button)findViewById(R.id.login_button);
input_email=(EditText)findViewById(R.id.login_email);
input_password=(EditText)findViewById(R.id.login_password);
btnSignup=(TextView)findViewById(R.id.sign_up);
btnForgotPass=(TextView)findViewById(R.id.forgot_password);
activity_main=(RelativeLayout)findViewById(R.id.activity_main);

btnSignup.setOnClickListener(this);
btnForgotPass.setOnClickListener(this);
btnLogin.setOnClickListener(this);

//Init Firebase Auth
auth=FirebaseAuth.getInstance();

//Check already session, if ok--->dashboard

if(auth.getCurrentUser() !=null)
startActivity(new Intent(MainActivity.this,dashboard.class));
}

@Override
public void onClick(View view) {

if(view.getId()==R.id.forgot_password)
{
startActivity(new Intent (MainActivity.this,Forgotpassword.class));
finish();
}
else if(view.getId()==R.id.sign_up)
{
startActivity(new Intent (MainActivity.this,Signup.class));
finish();
}
else if(view.getId()==R.id.login_button)
{
loginUser(input_email.getText().toString(),input_password.getText().toString());
}
}

private void loginUser(String email,final String password) {
auth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {

@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (!task.isSuccessful())
{
if (password.length() < 6)
{
Snackbar snackbar = Snackbar.make(activity_main, "Password should be more than 6 characters", Snackbar.LENGTH_SHORT);
snackbar.show();
}
}
else
{
startActivity(new Intent(MainActivity.this, dashboard.class));
}
}

});

}
}

这是activity_main.xml

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="16dp"
android:paddingTop="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:background="@drawable/login"
tools:context="com.mobility.mobilityindia.MainActivity">

<ImageView
android:id="@+id/logo"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_margin="10dp"
app:srcCompat="@drawable/siemenslogo" />

<android.support.design.widget.TextInputLayout
android:layout_below="@+id/logo"
android:id="@+id/login_input_email"
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<EditText
android:id="@+id/login_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/edittext_background"
android:hint=" Enter Email ID"
android:inputType="textEmailAddress"
android:maxLines="1" />

</android.support.design.widget.TextInputLayout>


<android.support.design.widget.TextInputLayout

android:layout_below="@+id/login_input_email"
android:id="@+id/login_input_password"
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<EditText
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:id="@+id/login_password"
android:background="@drawable/edittext_background"
android:inputType="textPassword"
android:visibility="visible"
android:hint=" Enter Password"
android:maxLines="1" />
</android.support.design.widget.TextInputLayout>

<Button
android:id="@+id/login_button"
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/login_input_password"
android:text="Sign In"
android:textAllCaps="false" />

<TextView
android:id="@+id/forgot_password"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/login_button"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:clickable="true"
android:text="Forgot Password ?"
android:textColor="@android:color/background_light"
android:textStyle="bold" />


<LinearLayout
android:id="@+id/login_layout_or"
android:layout_below="@+id/forgot_password"
android:gravity="center"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<view
android:layout_width="200dp"
android:layout_height="2dp"
android:background="#FFDFDCDD"
android:layout_margin="5dp" />

<TextView
android:padding="5dp"
android:text="OR"
android:textStyle="bold"
android:textColor="#FFDFDCDD"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<view
android:layout_width="200dp"
android:layout_height="2dp"
android:background="#FFDFDCDD"
android:layout_margin="5dp" />

</LinearLayout>

<TextView
android:id="@+id/sign_up"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/login_layout_or"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:clickable="true"
android:text="Sign Up"
android:textColor="@android:color/background_light"
android:textStyle="bold" />
</RelativeLayout>

相关的 logcat 详细信息(根据我的说法)是

07-07 16:16:32.072 3443-3443/? I/zygote: Not late-enabling -Xcheck:jni (already on)
07-07 16:16:32.088 3443-3443/? W/zygote: Unexpected CPU variant for X86 using defaults: x86
07-07 16:16:34.086 3443-3529/com.mobility.mobilityindia W/zygote: Verification of void com.google.android.gms.internal.zzbdd.zzqt() took 109.209ms
07-07 16:16:34.244 3443-3455/com.mobility.mobilityindia W/zygote: Suspending all threads took: 102.994ms
07-07 16:16:34.377 3443-3529/com.mobility.mobilityindia W/zygote: Verification of void com.google.android.gms.internal.zzbdd.zzqx() took 133.395ms
07-07 16:16:34.513 3443-3459/com.mobility.mobilityindia I/zygote: Background concurrent copying GC freed 20112(2MB) AllocSpace objects, 0(0B) LOS objects, 73% free, 542KB/2MB, paused 49.505ms total 82.869ms
07-07 16:16:34.531 3443-3459/com.mobility.mobilityindia W/zygote: Suspending all threads took: 10.382ms
07-07 16:16:34.572 3443-3443/com.mobility.mobilityindia I/FA: App measurement is starting up, version: 11020
07-07 16:16:34.572 3443-3443/com.mobility.mobilityindia I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
07-07 16:16:34.718 3443-3455/com.mobility.mobilityindia W/zygote: Suspending all threads took: 76.453ms
07-07 16:16:34.807 3443-3568/com.mobility.mobilityindia I/DynamiteModule: Considering local module com.google.android.gms.flags:2 and remote module com.google.android.gms.flags:0
07-07 16:16:34.807 3443-3568/com.mobility.mobilityindia I/DynamiteModule: Selected local version of com.google.android.gms.flags
07-07 16:16:34.837 3443-3529/com.mobility.mobilityindia W/zygote: Verification of int android.support.v4.util.ArrayMap$1.colGetSize() took 100.656ms
07-07 16:16:34.884 3443-3443/com.mobility.mobilityindia V/FA: Collection enabled
07-07 16:16:34.885 3443-3443/com.mobility.mobilityindia V/FA: App package, google app id: com.mobility.mobilityindia, 1:308094300316:android:8bb92942b462bf39
07-07 16:16:34.898 3443-3443/com.mobility.mobilityindia I/FA: To enable faster debug mode event logging run:
adb shell setprop debug.firebase.analytics.app com.mobility.mobilityindia
07-07 16:16:34.898 3443-3443/com.mobility.mobilityindia D/FA: Debug-level message logging enabled
07-07 16:16:35.021 3443-3568/com.mobility.mobilityindia W/DynamiteModule: Local module descriptor class for com.google.android.gms.crash not found.
07-07 16:16:35.072 3443-3568/com.mobility.mobilityindia W/zygote: Skipping duplicate class check due to unrecognized classloader
07-07 16:16:35.120 3443-3568/com.mobility.mobilityindia I/DynamiteModule: Considering local module com.google.android.gms.crash:0 and remote module com.google.android.gms.crash:4
07-07 16:16:35.120 3443-3568/com.mobility.mobilityindia I/DynamiteModule: Selected remote version of com.google.android.gms.crash, version >= 4
07-07 16:16:35.218 3443-3455/com.mobility.mobilityindia W/zygote: Suspending all threads took: 74.292ms
07-07 16:16:35.271 3443-3568/com.mobility.mobilityindia W/zygote: Skipping duplicate class check due to unrecognized classloader
07-07 16:16:35.294 3443-3529/com.mobility.mobilityindia W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
07-07 16:16:35.304 3443-3443/com.mobility.mobilityindia V/FA: Cancelling job. JobID: -631849166
07-07 16:16:35.335 3443-3568/com.mobility.mobilityindia I/FirebaseCrashApiImpl: FirebaseCrashApiImpl created by ClassLoader p[DexPathList[[zip file "/data/user_de/0/com.google.android.gms/app_chimera/m/00000004/DynamiteModulesC_GmsCore_prodmnc_alldpi_release.apk"],nativeLibraryDirectories=[/data/user_de/0/com.google.android.gms/app_chimera/m/00000004/n/x86, /system/lib, /system/vendor/lib]]]
07-07 16:16:35.351 3443-3568/com.mobility.mobilityindia I/FirebaseCrash: FirebaseCrash reporting loaded - com.google.android.gms.internal.ml@c481c82
07-07 16:16:35.405 3443-3443/com.mobility.mobilityindia V/FA: Registered activity lifecycle callback
07-07 16:16:35.411 3443-3443/com.mobility.mobilityindia I/FirebaseInitProvider: FirebaseApp initialization successful
07-07 16:16:35.463 3443-3443/com.mobility.mobilityindia I/InstantRun: starting instant run server: is main process
07-07 16:16:35.649 3443-3569/com.mobility.mobilityindia I/DynamiteModule: Considering local module com.google.android.gms.flags:2 and remote module com.google.android.gms.flags:0
07-07 16:16:35.650 3443-3569/com.mobility.mobilityindia I/DynamiteModule: Selected local version of com.google.android.gms.flags
07-07 16:16:35.733 3443-3614/com.mobility.mobilityindia V/FA: Using measurement service
07-07 16:16:35.735 3443-3614/com.mobility.mobilityindia V/FA: Connecting to remote service
07-07 16:16:35.992 3443-3529/com.mobility.mobilityindia W/GooglePlayServicesUtil: Google Play services out of date. Requires 11020000 but found 10930470
07-07 16:16:35.994 3443-3614/com.mobility.mobilityindia W/GooglePlayServicesUtil: Google Play services out of date. Requires 11020000 but found 10930470
07-07 16:16:36.060 3443-3614/com.mobility.mobilityindia V/FA: Using measurement service
07-07 16:16:36.061 3443-3614/com.mobility.mobilityindia V/FA: Connection attempt already in progress
07-07 16:16:36.133 3443-3569/com.mobility.mobilityindia W/DynamiteModule: Local module descriptor class for com.google.android.gms.crash not found.
07-07 16:16:36.781 3443-3443/com.mobility.mobilityindia V/FA: onActivityCreated
07-07 16:16:36.932 3443-3569/com.mobility.mobilityindia E/FirebaseCrash: Failed to initialize crash reporting: Can't create handler inside thread that has not called Looper.prepare()
07-07 16:16:36.940 3443-3570/com.mobility.mobilityindia E/FirebaseCrash: Failed waiting for crash api to load.
java.lang.InterruptedException
at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedNanos(AbstractQueuedSynchronizer.java:1063)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.tryAcquireSharedNanos(AbstractQueuedSynchronizer.java:1352)
at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:278)
at com.google.firebase.crash.FirebaseCrash.zzFc(Unknown Source:6)
at com.google.firebase.crash.FirebaseCrash.zza(Unknown Source:0)
at com.google.firebase.crash.zza.run(Unknown Source:2)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
07-07 16:16:37.716 3443-3455/com.mobility.mobilityindia I/zygote: Waiting for a blocking GC ObjectsAllocated
07-07 16:16:37.725 3443-3443/com.mobility.mobilityindia I/TextInputLayout: EditText added is not a TextInputEditText. Please switch to using that class instead.
07-07 16:16:37.735 3443-3443/com.mobility.mobilityindia I/TextInputLayout: EditText added is not a TextInputEditText. Please switch to using that class instead.
07-07 16:16:37.753 3443-3443/com.mobility.mobilityindia D/AndroidRuntime: Shutting down VM
07-07 16:16:37.755 3443-3443/com.mobility.mobilityindia E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mobility.mobilityindia, PID: 3443
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mobility.mobilityindia/com.mobility.mobilityindia.MainActivity}: android.view.InflateException: Binary XML file line #91: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6540)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: android.view.InflateException: Binary XML file line #91: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:767)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:733)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:827)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:869)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:827)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:289)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.mobility.mobilityindia.MainActivity.onCreate(MainActivity.java:33)
at android.app.Activity.performCreate(Activity.java:6980)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6540)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
07-07 16:16:37.759 3443-3443/com.mobility.mobilityindia E/UncaughtException: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mobility.mobilityindia/com.mobility.mobilityindia.MainActivity}: android.view.InflateException: Binary XML file line #91: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6540)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: android.view.InflateException: Binary XML file line #91: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:767)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:733)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:827)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:869)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:827)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:289)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.mobility.mobilityindia.MainActivity.onCreate(MainActivity.java:33)
at android.app.Activity.performCreate(Activity.java:6980)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6540)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
07-07 16:16:37.823 3443-3459/com.mobility.mobilityindia I/zygote: NativeAllocBackground concurrent copying GC freed 5277(990KB) AllocSpace objects, 5(100KB) LOS objects, 55% free, 1239KB/2MB, paused 5.719ms total 310.202ms
07-07 16:16:37.824 3443-3455/com.mobility.mobilityindia I/zygote: WaitForGcToComplete blocked for 107.393ms for cause ObjectsAllocated
07-07 16:16:38.670 3443-3455/com.mobility.mobilityindia W/zygote: Suspending all threads took: 15.516ms

包含'MainActivity.java:33'的行颜色为蓝色

最佳答案

改变

<view

<View

在这两个地方

关于java - 在 android studio 中编译应用程序时运行时错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44969174/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com