Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
693 views
in Technique[技术] by (71.8m points)

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

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!

question from:https://stackoverflow.com/questions/65926400/tracking-down-error-reported-in-pre-launch-report-java-lang-nullpointerexcepti

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...