Search code examples
androidandroid-studioandroid-debug

Logcat error in BottomNavigationView Listener


While running my app on debug mode, a logcat error occurs on opening an Activity with a BottomNavigationListener. There doesn't seem to be an "error" in the code. Could it be caused by using depreciated dependencies or API? Thanks for any help!

Here's the blue highlighted line from logcat at com.example.chemicalequationbalancer.HelpGuide.onCreate(HelpGuide.java:37)

Here's line 37 navigation.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { followed by the code of the same activity added below:

The HelpGuide.java class imports: (Most of my classes extend 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;

The BottomNavigationView code in the 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$2 }
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$2 }
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$2 }
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$2 }
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$2 }
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

Please ask for any extra file or piece of code needed! Thanks once again!

EDIT: Logcat added

<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" />

The menu drawer xml file:

<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"/>

This menu does appear on the main activity. Just when I click on the HelpGuide activity or the other activity which also uses this navbar, the app crashes. 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();

    }
}

Solution

  • Actually your helpguide activity dont have the reference of xml file and you have to set content view in activity like below.

          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();
    
    }
    }
    

    and add your bottom navigation view in help guide xml view.

    <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" />