Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tracking down error reported in pre-launch report - java.lang.NullPointerException - android.accounts.Account

Tags:

android

I've recently updated my first android app in the play store, and the pre-launch report has reported one error on a particular device. The stack trace provided is as follows:

FATAL EXCEPTION: main
Process: com.google.android.gm, PID: 9714
java.lang.NullPointerException: Attempt to invoke virtual method 'android.accounts.Account com.android.mail.providers.Account.b()' on a null object reference
    at dgg.Z(PG:3)
    at dgg.onPrepareOptionsMenu(PG:6)
    at com.google.android.gm.ComposeActivityGmail.onPrepareOptionsMenu(PG:1)
    at android.app.Activity.onPreparePanel(Activity.java:4137)
    at gn.onPreparePanel(PG:2)
    at vz.onPreparePanel(Unknown Source:2)
    at tm.onPreparePanel(PG:3)
    at tv.a(PG:192)
    at tv.f(PG:7)
    at tc.run(PG:2)
    at android.os.Handler.handleCallback(Handler.java:883)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:237)
    at android.app.ActivityThread.main(ActivityThread.java:8016)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1076)

The problem is that I was hoping to see one of my files and a line number in the above trace, but there isn't, so I'm not sure how to track down the cause of this error.

The trace mentions 'ComposeActivityGmail'. The only place in my app that has anything to do with Gmail is an option in my settings menu that launches a 'send email' intent using the following code, so I'm guessing the error is somewhere in here.

public class SettingsMenuFragment extends PreferenceFragmentCompat {
    @Override
    public void onCreatePreferences(Bundle bundle, String s) {

        addPreferencesFromResource(R.xml.app_preferences);
        Preference feedbackPreference = findPreference("keyFeedback");

        Objects.requireNonNull(feedbackPreference).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
            @Override
            public boolean onPreferenceClick(Preference preference) {

                Intent intent = new Intent(Intent.ACTION_SENDTO);
                intent.setData(Uri.parse("mailto:")); // only email apps should handle this
                intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"[email protected]"});
                intent.putExtra(Intent.EXTRA_SUBJECT, "Fake Feedback");
                if (intent.resolveActivity(requireActivity().getPackageManager()) != null) {
                    startActivity(intent);
                }
                return true;
            }
        });

Does anyone have any advice on how to understand the stack trace a bit better, or what could be wrong in the following code snippet?

Update So the device that experienced the problem in the pre-launch report was a Samsung. I've sourced a Samsung device myself and managed to recreate the issue. When I click on the feedback preference, the email client selection popup opened, but my app died. I then plugged the phone into my laptop and ran the same codebase in debug mode in android studio, but it worked perfectly. Installed the app from the play store again (still same version as before) and now it works faultlessly. So confused!

like image 689
pledgeX Avatar asked Sep 12 '25 08:09

pledgeX


2 Answers

There is no way to resolve this issue. I think it is just a problem with the old version of the Gmail application and is figured out on the current version. If the user updates the Gmail application, the error will not reproduce.

I succeed in reproducing this exception. I have an Android 10 Samsung smartphone. And I reset the phone and tried to launch Gmail from my app. That time the issue occurred. The Gmail version was 2019.11.21.283644823.release After updating the Gmail app, the issue did not occur again.

like image 69
Hyunchul Eddy Kim Avatar answered Sep 14 '25 00:09

Hyunchul Eddy Kim


I think error is not from your side, the google play console gives you error because the google will automatically random test your application.

During testing in application may have share feature and it will trigger, so from google automate random test is done via simulation, I think.

So basically, when share feature is trigger and select any google application like Gmail or other which is require google login, so simulation not available and login application,

that is the reason for this error.

like image 23
Gaurav Mandlik Avatar answered Sep 13 '25 22:09

Gaurav Mandlik