Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ChangelogBuilder.getCustomTitle throws exception #24

Open
bastianpedersen opened this issue Aug 4, 2023 · 2 comments
Open

ChangelogBuilder.getCustomTitle throws exception #24

bastianpedersen opened this issue Aug 4, 2023 · 2 comments

Comments

@bastianpedersen
Copy link

My app uses this library. While it works, I see a lot of noise in my Crashlytics logs in regards to this exception. More specifically, this is the exception:

Caused by java.lang.NullPointerException: Attempt to read from field 'java.lang.String f8.a.l' on a null object reference at com.michaelflisar.changelog.ChangelogBuilder.getCustomTitle(ChangelogBuilder.java:217) at com.michaelflisar.changelog.internal.ChangelogActivity.onCreate(ChangelogActivity.java:55) at android.app.Activity.performCreate(Activity.java:7009) at android.app.Activity.performCreate(Activity.java:7000) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856) at android.app.ActivityThread.-wrap11() at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6494) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

I have not been able to find any solution, so I have simply wrapped my code in a try-catch for now.

@MFlisar
Copy link
Owner

MFlisar commented Aug 4, 2023

Are you only starting the ChangelogActivity via following function:

public static Intent createIntent(Context context, ChangelogBuilder changelogBuilder, Integer theme, boolean themeHasActionBar) {
Intent intent = new Intent(context, ChangelogActivity.class);
intent.putExtra("builder", changelogBuilder);
intent.putExtra("theme", theme == null ? -1 : theme);
intent.putExtra("themeHasActionBar", themeHasActionBar);
return intent;
}

If the line numbers inside your log are correct, it seems like there is no ChangelogBuilder found inside the ChangelogActivity which can only happen if you start the activity in another way than the code block above would do...

@bastianpedersen
Copy link
Author

Right now I am doing this:

 try {
                val builder = ChangelogBuilder()
                    .withTitle("App changelog")
                    .withManagedShowOnStart(false)
                    .withRateButton(false)
                    .withMinVersionToShow(0)

                builder.buildAndShowDialog(
                    requireActivity() as? AppCompatActivity,
                    requireContext().isDarkTheme()
                )
            } catch (ex: Exception) {
                Snackbar.make(binding.scrollView, "Failed to open changelog.", Snackbar.LENGTH_SHORT).show()
            }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants