ChatSDK initialize throwing InvocationTargetException error

148 Views Asked by At

Okay so, I am currently integrating chatSDK into a pre-existing app. This is all fine, but when i try to call ChatSDK.ui().startSplashScreenActivity(context); it throws an errors that it was invoked on a null pointer.

I managed to narrow this down to ChatSDK.initialize(context, builder.build(), FirebaseNetworkAdapter.class, BaseInterfaceAdapter.class); Which was throwing java.lang.reflect.InvocationTargetException. In the stack trace this was also shown at co.chatsdk.core.session.ChatSDK.initialize(ChatSDK.java:86)

--> which is :shared().setNetworkAdapter(networkAdapterClass.getConstructor().newInstance());

So from what I gather, there is something funky going on with the network adapter, i.e my connection to firebase (works with another chatsdk app), or internet connection? I'm not quite sure how to go forward this this so would really appreciate your help.

Here is the code for reference. Thank you

    Context context = getApplicationContext();

        try {
            // Create a new configuration
            Configuration.Builder builder = new Configuration.Builder();

            // Perform any other configuration steps (optional)
            builder.firebaseRootPath("prod");

            // Initialize the Chat SDK
            //Configuration.Builder config = new Configuration.Builder(context);
            ChatSDK.initialize(context, builder.build(), FirebaseNetworkAdapter.class, BaseInterfaceAdapter.class);

            // File storage is needed for profile image upload and image messages
            FirebaseFileStorageModule.activate();

            // Push notification module
            //FirebasePushModule.activate();
            // Activate any other modules you need.
            // ...


        } catch (Exception e) {
            // Handle any exceptions
            e.printStackTrace();
            Log.e("chatsdkError",e.toString());
        }
public class Messages extends AppCompatActivity {
    @Override
    protected  void onCreate(Bundle onSavedInstance){
        super.onCreate(onSavedInstance);
        setContentView(R.layout.activity_messages);

        Context context = getApplicationContext();
        ChatSDK.ui().startSplashScreenActivity(context);
    }
}

And lastly, here is some of the stack trace that i think is important

W/System.err: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.newInstance0(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
        at co.chatsdk.core.session.ChatSDK.initialize(ChatSDK.java:86)
        at com.ul.pinter.Home.onCreate(Home.java:101)
        at android.app.Activity.performCreate(Activity.java:7815)
        at android.app.Activity.performCreate(Activity.java:7804)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1318)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3349)
0

There are 0 best solutions below