1

好的,我目前正在将 chatSDK 集成到一个预先存在的应用程序中。这一切都很好,但是当我尝试调用ChatSDK.ui().startSplashScreenActivity(context);它时会抛出一个错误,它是在空指针上调用的。

我设法将其缩小到ChatSDK.initialize(context, builder.build(), FirebaseNetworkAdapter.class, BaseInterfaceAdapter.class); 抛出 java.lang.reflect.InvocationTargetException。在堆栈跟踪中也显示了这一点 at co.chatsdk.core.session.ChatSDK.initialize(ChatSDK.java:86)

--> 这是:shared().setNetworkAdapter(networkAdapterClass.getConstructor().newInstance());

因此,据我所知,网络适配器发生了一些奇怪的事情,即我与 firebase 的连接(与另一个 chatsdk 应用程序一起使用)或互联网连接?我不太确定如何进行此操作,因此非常感谢您的帮助。

这是供参考的代码。谢谢

    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);
    }
}

最后,这是我认为重要的一些堆栈跟踪

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)
4

0 回答 0