Logcat BottomNavigationView 侦听器中的错误

Logcat error in BottomNavigationView Listener

虽然 运行 我的应用程序处于调试模式,但在使用 BottomNavigationListener 打开 Activity 时出现 logcat 错误。代码中似乎没有“错误”。会不会是使用了折旧的依赖或者API导致的?感谢您的帮助!

这是 logcat at com.example.chemicalequationbalancer.HelpGuide.onCreate(HelpGuide.java:37)

中突出显示的蓝色行

这是第 37 行 navigation.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {,后面是下面添加的相同 activity 的代码:

HelpGuide.java class 导入:(我的大多数 classes 扩展了 AppCompatActivity)

import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;

import com.google.android.material.bottomnavigation.BottomNavigationView;

import mehdi.sakout.aboutpage.AboutPage;
import mehdi.sakout.aboutpage.BuildConfig;
import mehdi.sakout.aboutpage.Element;

BottomNavigationView代码在activity:

BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.nav_bottom);
        navigation.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                switch (item.getItemId()) {
                    case R.id.nav_home:
                        Intent a = new Intent(AboutUs.this, MainActivity.class);
                        startActivity(a);
                        break;

                    case R.id.nav_aboutus:
                        break;
                    case R.id.nav_help:
                        Intent b = new Intent(AboutUs.this, HelpGuide.class);
                        startActivity(b);
                        break;

                }
                return false;
            }
        });

ActivityMainfest.xml

<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.ChemicalEquationBalancer">


        <activity android:name="com.example.chemicalequationbalancer.AboutUs" android:theme="@style/Theme.ChemicalEquationBalancer.NoActionBar"/>
        <activity android:name="com.example.chemicalequationbalancer.HelpGuide" android:theme="@style/Theme.ChemicalEquationBalancer.NoActionBar"/>
        <activity android:name="com.example.chemicalequationbalancer.eleView" android:theme="@style/Theme.ChemicalEquationBalancer.NoActionBar"/>


        <activity
            android:name="com.example.chemicalequationbalancer.MainActivity"
            android:label="@string/app_name"
            android:theme="@style/Theme.ChemicalEquationBalancer.NoActionBar" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

Logcat:

2021-02-17 18:19:13.303 20042-20042/com.example.chemicalequationbalancer E/ANR_LOG: >>> msg'1s executing time is too long
2021-02-17 18:19:13.303 20042-20042/com.example.chemicalequationbalancer E/ANR_LOG: Blocked msg = { when=-2s884ms what=159 target=android.app.ActivityThread$H obj=ClientTransaction hashCode, mActivityToken = android.os.BinderProxy@ec0d4dc } , cost  = 1542 ms
2021-02-17 18:19:13.303 20042-20042/com.example.chemicalequationbalancer E/ANR_LOG: >>>Current msg List is:
2021-02-17 18:19:13.304 20042-20042/com.example.chemicalequationbalancer E/ANR_LOG: Current msg <1>  = { when=-2s883ms what=159 target=android.app.ActivityThread$H obj=ClientTransaction hashCode, mActivityToken = android.os.BinderProxy@ec0d4dc }
2021-02-17 18:19:13.304 20042-20042/com.example.chemicalequationbalancer E/ANR_LOG: Current msg <2>  = { when=-2s882ms what=0 target=android.app.ActivityThread$H callback=com.android.internal.util.function.pooled.PooledLambdaImpl }
2021-02-17 18:19:13.305 20042-20042/com.example.chemicalequationbalancer E/ANR_LOG: Current msg <3>  = { when=-2s882ms what=149 target=android.app.ActivityThread$H obj=android.os.BinderProxy@ec0d4dc }
2021-02-17 18:19:13.306 20042-20042/com.example.chemicalequationbalancer E/ANR_LOG: Current msg <4>  = { when=-2s403ms what=159 target=android.app.ActivityThread$H obj=ClientTransaction hashCode, mActivityToken = android.os.BinderProxy@ec0d4dc }
2021-02-17 18:19:13.306 20042-20042/com.example.chemicalequationbalancer E/ANR_LOG: Current msg <5>  = { when=-2s403ms what=137 target=android.app.ActivityThread$H arg1=1 obj=android.os.BinderProxy@ec0d4dc }
2021-02-17 18:19:13.307 20042-20042/com.example.chemicalequationbalancer E/ANR_LOG: Current msg <6>  = { when=-1s126ms what=0 target=android.os.Handler callback=androidx.core.content.res.ResourcesCompat$FontCallback }
2021-02-17 18:19:13.307 20042-20042/com.example.chemicalequationbalancer E/ANR_LOG: Current msg <7>  = { when=-390ms what=0 target=android.os.Handler callback=androidx.core.content.res.ResourcesCompat$FontCallback }
2021-02-17 18:19:13.308 20042-20042/com.example.chemicalequationbalancer E/ANR_LOG: Current msg <8>  = { when=-382ms what=0 target=android.os.Handler callback=androidx.core.content.res.ResourcesCompat$FontCallback }
2021-02-17 18:19:13.308 20042-20042/com.example.chemicalequationbalancer E/ANR_LOG: Current msg <9>  = { when=-332ms what=0 target=android.os.Handler callback=androidx.core.content.res.ResourcesCompat$FontCallback }
2021-02-17 18:19:13.309 20042-20042/com.example.chemicalequationbalancer E/ANR_LOG: Current msg <10>  = { when=-325ms what=0 target=android.os.Handler callback=androidx.core.content.res.ResourcesCompat$FontCallback }
2021-02-17 18:19:13.309 20042-20042/com.example.chemicalequationbalancer E/ANR_LOG: >>>CURRENT MSG DUMP OVER<<<
2021-02-17 18:19:13.329 686-20185/? E/MDP: DpIspStream::waitComplete m_DREPABufferStartIndexList empty
2021-02-17 18:19:13.389 686-20185/? E/MDP: DpIspStream::waitComplete m_DREPABufferStartIndexList empty
2021-02-17 18:19:13.449 686-20185/? E/MDP: DpIspStream::waitComplete m_DREPABufferStartIndexList empty
2021-02-17 18:19:13.510 686-20185/? E/MDP: DpIspStream::waitComplete m_DREPABufferStartIndexList empty
2021-02-17 18:19:13.533 20042-20217/com.example.chemicalequationbalancer E/GED: Failed to get GED Log Buf, err(0)
2021-02-17 18:19:13.571 686-20185/? E/MDP: DpIspStream::waitComplete m_DREPABufferStartIndexList empty
2021-02-17 18:19:13.610 681-681/? E/Situation: processEvent, handle:26, flush_action:0
2021-02-17 18:19:13.611 681-681/? E/libc: Access denied finding property "ro.build.flavor"
2021-02-17 18:19:13.632 686-20185/? E/MDP: DpIspStream::waitComplete m_DREPABufferStartIndexList empty
2021-02-17 18:19:13.691 686-20185/? E/MDP: DpIspStream::waitComplete m_DREPABufferStartIndexList empty
2021-02-17 18:19:13.737 20042-20217/com.example.chemicalequationbalancer E/ion: ioctl c0044901 failed with code -1: Invalid argument
2021-02-17 18:19:13.738 20042-20217/com.example.chemicalequationbalancer E/GED: Failed to get GED Log Buf, err(0)
2021-02-17 18:19:13.739 1192-1503/? E/TaskPersister: File error accessing recents directory (directory doesn't exist?).
2021-02-17 18:19:13.749 686-20185/? E/MDP: DpIspStream::waitComplete m_DREPABufferStartIndexList empty
2021-02-17 18:19:13.811 686-20185/? E/MDP: DpIspStream::waitComplete m_DREPABufferStartIndexList empty
2021-02-17 18:19:13.871 686-20185/? E/MDP: DpIspStream::waitComplete m_DREPABufferStartIndexList empty
2021-02-17 18:19:13.930 686-20185/? E/MDP: DpIspStream::waitComplete m_DREPABufferStartIndexList empty
2021-02-17 18:19:13.938 739-817/? E/facereg_hal: do_identify failed FACE_ERROR_CANCELLED
2021-02-17 18:19:13.989 686-20185/? E/MDP: DpIspStream::waitComplete m_DREPABufferStartIndexList empty
2021-02-17 18:19:14.030 1192-2967/? E/PowerHalWrapper: <amsBoostStop> duration: 6000ms
2021-02-17 18:19:14.077 681-1296/? E/SensorContext: activate, handle = 4, index = 3
2021-02-17 18:19:14.143 681-1296/? E/SensorContext: activate, handle = 3, index = 2
2021-02-17 18:19:14.178 681-681/? E/SensorContext: activate, handle = 3, index = 2
2021-02-17 18:19:14.179 681-681/? E/SensorContext: activate, handle = 1, index = 1
2021-02-17 18:19:14.184 681-681/? E/SensorContext: activate, handle = 0, index = 0
2021-02-17 18:19:14.189 681-681/? E/SensorContext: activate, handle = 0, index = 0
2021-02-17 18:19:14.360 1192-2967/? E/Process: get_ion_cache_memory: Unable to open /d/ion/heaps/system
2021-02-17 18:19:16.568 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:16.590 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:16.606 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:16.638 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:16.721 741-741/? E/CryptoEngInvokeCommand: crypto_eng_invoke_command set pms flag
2021-02-17 18:19:16.742 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:16.782 1192-1292/? E/DisplayEventDispatcher: dispatcher 0x7af60b7be0 ~ last event processed while scheduling was for 26200050
2021-02-17 18:19:16.799 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:16.801 2512-3009/? E/neodaemon: ERROR  elsaNotifyAppSwitch is NULL
2021-02-17 18:19:16.804 741-741/? E/cryptoeng_hidl: commondcs service exist.
2021-02-17 18:19:16.843 1192-3201/? E/OifaceUtil: Cannot connect to OifaceService
2021-02-17 18:19:16.846 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:16.854 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:16.858 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:16.860 1825-1825/? E/OppoTelephonyFunction: leon operatorNumic is not included in our romupdate xml file 
2021-02-17 18:19:16.861 1825-1825/? E/m.android.phon: Invalid ID 0x00000000.
2021-02-17 18:19:16.865 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:16.881 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:16.892 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:16.900 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:16.912 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:16.950 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:17.001 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:17.016 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:17.039 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:17.045 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:17.078 19888-19970/? E/GED: Failed to get GED Log Buf, err(0)
2021-02-17 18:19:17.087 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:17.110 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:17.123 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:17.155 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:17.173 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:17.177 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:17.216 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:17.248 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:17.252 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:17.252 4823-17448/? E/CheckPermission: _bluetooth code = 14 
2021-02-17 18:19:17.263 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:17.270 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:17.333 1192-1338/? E/WifiScanRequestProxy: Scan failure received. reason: -1,description: not available
2021-02-17 18:19:17.342 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:17.350 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:18.452 19888-19888/? E/DisplayEventDispatcher: dispatcher 0x7b0181d280 ~ last event processed while scheduling was for 26201742
2021-02-17 18:19:18.472 19982-19985/? E/adbd: remote usb: read terminated (message): No such device
2021-02-17 18:19:18.568 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:18.617 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:18.622 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:18.636 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:18.643 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:18.645 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:18.647 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:18.924 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:18.933 1192-1215/? E/NotificationService: Suppressing notification from package by user request.
2021-02-17 18:19:18.965 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:18.969 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:18.972 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:18.976 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:18.980 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:19.071 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:19.074 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:19.076 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:19.080 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:20.163 20042-20217/com.example.chemicalequationbalancer E/GED: Failed to get GED Log Buf, err(0)
2021-02-17 18:19:19.098 1192-1215/? E/NotificationService: Suppressing notification from package by user request.
2021-02-17 18:19:22.995 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:23.051 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:23.054 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:23.068 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:23.121 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:23.304 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:23.307 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:23.317 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:23.326 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:23.329 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:23.450 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:24.339 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:24.343 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:26.124 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:26.179 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:27.598 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:27.864 681-1296/? E/Situation: processEvent, handle:26, flush_action:0
2021-02-17 18:19:27.864 681-1296/? E/libc: Access denied finding property "ro.build.flavor"
2021-02-17 18:19:30.293 9892-9904/? E/rutils: releaseProcess gCount = 1
2021-02-17 18:19:31.407 2512-3009/? E/neodaemon: ERROR  elsaResume is NULL
2021-02-17 18:19:31.480 1192-3201/? E/OifaceUtil: Cannot connect to OifaceService
2021-02-17 18:19:31.490 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:31.493 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:31.766 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:32.100 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:32.130 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:32.148 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:32.222 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:32.345 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:32.367 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:33.032 1192-3236/? E/OifaceUtil: Cannot connect to OifaceService
2021-02-17 18:19:33.038 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:33.139 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:33.365 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:34.393 2512-3009/? E/neodaemon: ERROR  elsaResume is NULL
2021-02-17 18:19:34.433 1192-3211/? E/OifaceUtil: Cannot connect to OifaceService
2021-02-17 18:19:34.442 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:34.446 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:34.505 20042-20042/com.example.chemicalequationbalancer E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.chemicalequationbalancer, PID: 20042
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.chemicalequationbalancer/com.example.chemicalequationbalancer.HelpGuide}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.material.bottomnavigation.BottomNavigationView.setOnNavigationItemSelectedListener(com.google.android.material.bottomnavigation.BottomNavigationView$OnNavigationItemSelectedListener)' on a null object reference
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3197)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3334)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:113)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:71)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2025)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:226)
        at android.app.ActivityThread.main(ActivityThread.java:7191)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:499)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:942)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.material.bottomnavigation.BottomNavigationView.setOnNavigationItemSelectedListener(com.google.android.material.bottomnavigation.BottomNavigationView$OnNavigationItemSelectedListener)' on a null object reference
        at com.example.chemicalequationbalancer.HelpGuide.onCreate(HelpGuide.java:37)
        at android.app.Activity.performCreate(Activity.java:7376)
        at android.app.Activity.performCreate(Activity.java:7367)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3177)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3334) 
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:113) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:71) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2025) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:226) 
        at android.app.ActivityThread.main(ActivityThread.java:7191) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:499) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:942) 
2021-02-17 18:19:34.591 1192-1321/? E/InputDispatcher: channel 'a589010 com.example.chemicalequationbalancer/com.example.chemicalequationbalancer.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
2021-02-17 18:19:34.630 2512-3009/? E/neodaemon: ERROR  elsaNotifyAppSwitch is NULL
2021-02-17 18:19:34.645 1192-2916/? E/OifaceUtil: Cannot connect to OifaceService
2021-02-17 18:19:34.651 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL
2021-02-17 18:19:34.662 2512-3009/? E/neodaemon: ERROR  elsaGetPackageFreezing is NULL

请询问是否需要任何额外的文件或代码! 再次感谢!

编辑:Logcat 添加

<com.google.android.material.bottomnavigation.BottomNavigationView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/nav_bottom"
        android:layout_alignParentBottom="true"
        app:itemTextColor="@android:color/black"
        app:menu="@menu/drawer_view" />

菜单抽屉xml文件:

<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:title="Home"
        android:id="@+id/nav_home"
        android:icon="@drawable/ic_baseline_home"/>
    <item android:title="About Us"
        android:id="@+id/nav_aboutus"
        android:icon="@drawable/ic_baseline_abus"/>
    <item android:title="Help"
        android:id="@+id/nav_help"
        android:icon="@drawable/ic_baseline_help"/>

这个菜单确实出现在主 activity 上。就在我单击 HelpGuide activity 或其他也使用此导航栏的 activity 时,应用程序崩溃了。 HelpGuide.java:

import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;

import com.google.android.material.bottomnavigation.BottomNavigationView;

import mehdi.sakout.aboutpage.AboutPage;
import mehdi.sakout.aboutpage.BuildConfig;
import mehdi.sakout.aboutpage.Element;




public class HelpGuide extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        Element developersElement = new Element();
        developersElement.setTitle("Help Guide");

        BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.nav_bottom);
        navigation.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                switch (item.getItemId()) {
                    case R.id.nav_home:
                        Intent a = new Intent(HelpGuide.this, MainActivity.class);
                        startActivity(a);
                        break;
                    case R.id.nav_aboutus:
                        Intent b = new Intent(HelpGuide.this, AboutUs.class);
                        startActivity(b);
                        break;
                    case R.id.nav_help:

                        break;

                }
                return false;
            }
        });
        AboutPage aboutPage = new AboutPage(this)
                .isRTL(false)
                .setImage(R.mipmap.ic_launcher)
                .setDescription(getString(R.string.helpguide));


        View aboutPageView = aboutPage.create();

    }
}

实际上您的帮助指南 activity 没有 xml 文件的参考,您必须在 activity 中设置内容视图,如下所示。

      public class HelpGuide extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.yourxmlhelpguide); <----- here is the solution

    Element developersElement = new Element();
    developersElement.setTitle("Help Guide");

    BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.nav_bottom);
    navigation.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
            switch (item.getItemId()) {
                case R.id.nav_home:
                    Intent a = new Intent(HelpGuide.this, MainActivity.class);
                    startActivity(a);
                    break;
                case R.id.nav_aboutus:
                    Intent b = new Intent(HelpGuide.this, AboutUs.class);
                    startActivity(b);
                    break;
                case R.id.nav_help:

                    break;

            }
            return false;
        }
    });
    AboutPage aboutPage = new AboutPage(this)
            .isRTL(false)
            .setImage(R.mipmap.ic_launcher)
            .setDescription(getString(R.string.helpguide));


    View aboutPageView = aboutPage.create();

}
}

并在帮助指南 xml 视图中添加底部导航视图。

<com.google.android.material.bottomnavigation.BottomNavigationView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/nav_bottom"
    android:layout_alignParentBottom="true"
    app:itemTextColor="@android:color/black"
    app:menu="@menu/drawer_view" />