从 playstore 下载时应用程序崩溃

App crashes when downloaded from playstore

pp main activity 文件可以运行,但是当单击任何片段时它会崩溃。然而,当在设备和 android 模拟器上进行模拟时,它运行流畅。崩溃的logcat如下;

java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.Object[] java.util.Collection.toArray()' on a null object reference
        at java.util.ArrayList.addAll(ArrayList.java:588)
        at d.a$b.a(:14)
        at i.l$b$a$a.run(Unknown Source:37)
        at android.os.Handler.handleCallback(Handler.java:790)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:7025)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)

而开始片段的主要 activity 如下;

 private void selectDrawerItem(MenuItem menuItem) {
        Fragment fragment = null;
        Class fragmentClass;
        switch(menuItem.getItemId()) {
            case R.id.menu_1:
                fragmentClass = Fragment1.class;
                break;
            case R.id.menu_2:
                fragmentClass = Fragment2.class;
                break;
            case R.id.menu_3:
                fragmentClass = Fragment3.class;
                break;
            case R.id.menu_4:
                fragmentClass = Fragment4.class;
                break;
            case R.id.menu_5:
                fragmentClass = Fragment5.class;
                break;
            case R.id.menu_6:
                fragmentClass = Fragment6.class;
                break;
            case R.id.menu_7:
                fragmentClass = Fragment7.class;
                break;
            case R.id.menu_8:
                fragmentClass = Fragment8.class;
                break;
            case R.id.menu_9:
                fragmentClass = Fragment9.class;
                break;
            case R.id.menu_10:
                fragmentClass = Fragment10.class;
                break;
                case R.id.menu_11:
                fragmentClass = Fragment11.class;
                break;

                default:
                throw new IllegalStateException("Unexpected value: " + menuItem.getItemId());
        }
        try {
            fragment = (Fragment) fragmentClass.newInstance();
        } catch (Exception e) {
            e.printStackTrace();
        }


        // Insert the fragment by replacing any existing fragment
        FragmentManager fragmentManager = getSupportFragmentManager();
        assert fragment != null;
        fragmentManager.beginTransaction().replace(R.id.flContent, fragment).commit();

        // Highlight the selected item has been done by NavigationView
        menuItem.setChecked(false);
        // Set action bar title
        setTitle(menuItem.getTitle());
        // Close the navigation drawer
        mDrawer.closeDrawers();
    }

    @Override
    protected void onPostCreate(@Nullable Bundle savedInstanceState) {
        super.onPostCreate(savedInstanceState);
        drawerToggle.syncState();
    }

    @Override
    public void onConfigurationChanged(@NonNull Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        drawerToggle.onConfigurationChanged(newConfig);
    }

    @Override
    public void onBackPressed() {
        startActivity(new Intent(this, MainActivity.class));
            finish();
        }

有人可以指导为什么在 android studio

上运行流畅时 apk 文件中出现错误

在我的例子中,片段没有开始,所以我尝试从 gradle 中删除 minifyEnable 和 ShrinkResources (true) 并将其更改为

   buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
}

虽然增加了应用程序的大小,但崩溃问题得到了解决。