1

当我在模拟器上打开它时,该应用程序不断崩溃。这是 activity_main.xml 和我得到的错误。

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <androidx.fragment.app.FragmentContainerView
        android:id="@+id/main_nav_host"
        android:name="com.example.test_run.main.MainSessionNavHostFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:defaultNavHost="false" />

</androidx.constraintlayout.widget.ConstraintLayout>
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.test_run.MainActivity" on path: DexPathList[[zip file "/data/app/~~f3SDJdSMUvctPuzredlmhQ==/com.example.test_run-JMnAM1A0EvaUsPTrSDaFwA==/base.apk"],nativeLibraryDirectories=[/data/app/~~f3SDJdSMUvctPuzredlmhQ==/com.example.test_run-JMnAM1A0EvaUsPTrSDaFwA==/lib/arm64, /system/lib64, /system_ext/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
4

2 回答 2

0

你应该显示MainActivity.java/MainActivity.kotlinAndroidManifest.xml

于 2021-02-24T18:24:35.200 回答
0
tools:context=".you_acitivy_class_name"

在你的情况下,也许这是

tools:context=".MainActivity"

ConstraintLayout在下面添加此行

<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context=".MainActivity"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
于 2021-02-24T16:36:32.490 回答