Skip to content

Unable to validate SDK for Android using React Native SDK #1293

@Dacker15

Description

@Dacker15

Describe the bug

If I try to use validateSDKIntegration on Android, I get this error:

java.lang.NullPointerException: Attempt to invoke virtual method 'void io.branch.referral.validators.IntegrationValidatorDialog.SetTestResultForRowItem(int, java.lang.String, boolean, java.lang.String, java.lang.String)' on a null object reference
                                                                                                    	at io.branch.referral.validators.IntegrationValidator.doValidateWithAppConfig(IntegrationValidator.java:68)
                                                                                                    	at io.branch.referral.validators.IntegrationValidator.onAppConfigAvailable(IntegrationValidator.java:127)
                                                                                                    	at io.branch.referral.validators.ServerRequestGetAppConfig.onRequestSucceeded(ServerRequestGetAppConfig.java:28)
                                                                                                    	at io.branch.referral.ServerRequestQueue$BranchPostTask.onRequestSuccess(ServerRequestQueue.java:658)
                                                                                                    	at io.branch.referral.ServerRequestQueue$BranchPostTask.onPostExecuteInner(ServerRequestQueue.java:574)
                                                                                                    	at io.branch.referral.ServerRequestQueue$BranchPostTask.onPostExecute(ServerRequestQueue.java:559)
                                                                                                    	at io.branch.referral.ServerRequestQueue$BranchPostTask.onPostExecute(ServerRequestQueue.java:512)
                                                                                                    	at android.os.AsyncTask.finish(AsyncTask.java:771)
                                                                                                    	at android.os.AsyncTask.-$$Nest$mfinish(Unknown Source:0)
                                                                                                    	at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:788)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:106)
                                                                                                    	at android.os.Looper.loopOnce(Looper.java:201)
                                                                                                    	at android.os.Looper.loop(Looper.java:288)
                                                                                                    	at android.app.ActivityThread.main(ActivityThread.java:7872)
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
                                                                                                    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

Steps to reproduce

  1. Install React Native package using the instruction
  2. Call branch.validateSDKIntegration() inside an useEffect with zero dependencies on App.tsx

Expected behavior

The dialog with validation results should appear

SDK Version

5.18.1

Make and Model

Pixel 7 (Emulator)

OS

13

Additional Information/Context

Looking at the code on Branch-SDK/src/main/java/io/branch/referral/validators/IntegrationValidator.java

Branch.enableLogging(iBranchLoggingCallbacks);
instance.validateSDKIntegration(context);
instance.integrationValidatorDialog = new IntegrationValidatorDialog(context);

seems that instantiation of integrationValidatorDialog happens after validateSDKIntegration.
Rewriting this part in this way:

instance.integrationValidatorDialog = new IntegrationValidatorDialog(context);
Branch.enableLogging(iBranchLoggingCallbacks);
instance.validateSDKIntegration(context);

could fix my problem?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions