1

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)
alanfinnin
  • 23
  • 5
  • Does FireBaseNetworkAdapter class have a constructor which takes no parameters? – gizembrh Apr 07 '20 at 22:31
  • Yes, there is only one constructure and it is no args – alanfinnin Apr 07 '20 at 22:44
  • Hmm, what about BaseInterfaceAdapter? I'm asking because according to log stack, the sdk is trying to initialize a class via reflection, and it is expecting a no-arg constructor (here: java.lang.reflect.Constructor.newInstance0(Native Method)) – gizembrh Apr 07 '20 at 22:47
  • The BaseInterfaceAdapter doesn't have a no args, it expects a context, I think you might be right. Although I don't quite now how I would fix this. A class is expected in the initialize function. – alanfinnin Apr 07 '20 at 22:53
  • That should be the problem. If you create a constructor with an argument, then the no-args constructor is not created. Can't you pass the context later to the BaseInterfaceAdapter? – gizembrh Apr 08 '20 at 10:46
  • Acc tually strike that, after looking in in the init code itself, ```shared().setNetworkAdapter(networkAdapterClass.getConstructor().newInstance());``` Is called, which seems to deal with that issue – alanfinnin Apr 08 '20 at 10:58
  • After looking though it, FireBaseAdapter seems to be the problem – alanfinnin Apr 08 '20 at 12:04

0 Answers0