为了账号安全,请及时绑定邮箱和手机立即绑定

按钮不可点击+点击时应用程序崩溃

按钮不可点击+点击时应用程序崩溃

蛊毒传说 2023-08-16 09:52:37
这是崩溃错误 logcat,每次我在寄存器上计时时,应用程序都会崩溃。我的模拟器是 AndroidQ 模拟器设备上的 2GB RAM。2019-09-22 16:36:39.307 6454-6454/com.connex.connexsocial E/AndroidRuntime:致命异常:主进程:com.connex.connexsocial,PID:6454 android.content.ActivityNotFoundException:无法找到显式活动类{com.connex.connexsocial/com.connex.connexsocial.LoginActivity};您是否在 AndroidManifest.xml 中声明了此活动?在 android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1933) 在 android.app.Instrumentation.execStartActivity(Instrumentation.java:1616) 在 android.app.Activity.startActivityForResult(Activity.java:4487) 在 androidx.fragment。 app.FragmentActivity.startActivityForResult(FragmentActivity.java:676) 在 android.app.Activity.startActivityForResult(Activity.java:4445) 在 androidx.fragment。这是我的主要活动<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:background="#7ed957"    android:padding="20dp"    tools:contet=".MainActivity">    <ImageView        android:layout_height="match_parent"        android:layout_width="match_parent"        android:src="@drawable/logo1"        android:layout_centerHorizontal="true"        android:contentDescription="@string/todo" />        <!--Button: Register-->    <Button        android:id="@+id/register_btn"        android:text="@string/register"        android:layout_above="@+id/login_btn"        style="@style/Widget.AppCompat.Button.Colored"        android:layout_width="match_parent"        android:layout_height="wrap_content" /></RelativeLayout>每次我单击“登录”时都什么也不做,每次我单击“注册”时它都会崩溃。
查看完整描述

2 回答

?
杨魅力

TA贡献1811条经验 获得超5个赞

您需要在清单文件中声明 LoginActivity,如 AndroidManifest.xml

<activity
android:name="com.connex.connexsocial.LoginActivity"
     />


查看完整回答
反对 回复 2023-08-16
?
qq_花开花谢_0

TA贡献1835条经验 获得超6个赞

每当您的应用程序崩溃时,第一个调试步骤应该是检查您的 logcat,logcat 中总是有线索。如果您检查发布的日志,您将看到以下行:

android.content.ActivityNotFoundException:无法找到显式活动类 {com.connex.connexsocial/com.connex.connexsocial.LoginActivity};您是否在 AndroidManifest.xml 中声明了此活动?

从字面上看,这意味着您收到此错误是因为您尚未在清单中声明该活动

要解决此问题,只需将其粘贴到清单文件的应用程序元素中:

<activity android:name="com.connex.connexsocial.LoginActivity"></activity>

这种相同的调试模式几乎适用于所有崩溃事件。你总能从 logcat 中得到线索。


查看完整回答
反对 回复 2023-08-16
  • 2 回答
  • 0 关注
  • 76 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信