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

NullPointerException on AffirmPlugins.gson() #109

Open
sgbasaraner opened this issue Jan 20, 2022 · 5 comments
Open

NullPointerException on AffirmPlugins.gson() #109

sgbasaraner opened this issue Jan 20, 2022 · 5 comments

Comments

@sgbasaraner
Copy link

Hi, we run this SDK in production. We've recently faced with many crashes in our app's checkout page because of this issue, please find the stacktrace below:

com.affirm.android.CheckoutRequest in <init> at line 51
com.affirm.android.CheckoutRequest in <init> at line 56
com.affirm.android.CheckoutBaseActivity in onAttached at line 59
com.affirm.android.AffirmActivity in onCreate at line 52
android.app.Activity in performCreate at line 8041
android.app.Activity in performCreate at line 8030
android.app.Instrumentation in callActivityOnCreate at line 1307
android.app.ActivityThread in performLaunchActivity at line 3246
android.app.ActivityThread in handleLaunchActivity at line 3410
android.app.servertransaction.LaunchActivityItem in execute at line 83
android.app.servertransaction.TransactionExecutor in executeCallbacks at line 135
android.app.servertransaction.TransactionExecutor in execute at line 95
android.app.ActivityThread$H in handleMessage at line 2017
android.os.Handler in dispatchMessage at line 107
android.os.Looper in loop at line 214
android.app.ActivityThread in main at line 7397
java.lang.reflect.Method in invoke
com.android.internal.os.RuntimeInit$MethodAndArgsCaller in run at line 492
com.android.internal.os.ZygoteInit in main at line 935

For some reason the SDK is unable to locate gson. We also have an indirect dependency to gson, maybe that's causing the issue?

@wangdaliu
Copy link
Contributor

wangdaliu commented Mar 27, 2022

hi @sgbasaraner Can you check Affirm.initialize needs to be initialized in the application. If there is still this problem, can you help provide the sample code of how to call SDK?

@sgbasaraner
Copy link
Author

Hi, sure, we do initialize first like this:

Affirm.initialize(Affirm.Configuration.Builder("KEY")
    .setEnvironment(Affirm.Environment.PRODUCTION)
    .setMerchantName("Carla")
    .setLogLevel(Affirm.LOG_LEVEL_DEBUG)
    .setLocation(Affirm.Location.US)
    .build()
)

@wangdaliu
Copy link
Contributor

hi @sgbasaraner I have tried different gson versions, but this problem has not been reproduced. Do you have more detailed information? Or if you can reproduce it, PR is welcome. Thanks!

@sgbasaraner
Copy link
Author

Hi @wangdaliu , the issue still stands unfortunately. We use gson version 2.9.0, maybe that can help recreate it?

Screen Shot 2022-05-13 at 10 27 29

@wangdaliu
Copy link
Contributor

Hi @sgbasaraner Thanks for your detailed crash log, from the crash log, this null pointer occurs in AffirmPlugins.get()

Can you confirm that Affirm.initialize(Configuration) must be done in your Application#onCreate(), not your Activity#onCreate(Bundle)

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