chat-sdk-android icon indicating copy to clipboard operation
chat-sdk-android copied to clipboard

java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference

Open SimpleAesthetics opened this issue 9 years ago • 10 comments

when I add this party to my oncreate()

Context context = getApplicationContext();

I am getting a null pointer exception on this line

Configuration.Builder builder = new Configuration.Builder(context);

SimpleAesthetics avatar Nov 28 '17 21:11 SimpleAesthetics

What is the stack trace?

bensmiley avatar Nov 28 '17 21:11 bensmiley

how do i get that?

SimpleAesthetics avatar Nov 28 '17 21:11 SimpleAesthetics

What is the error message you're getting?

bensmiley avatar Nov 28 '17 21:11 bensmiley

E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: reboot.grouper, PID: 8958
                  java.lang.RuntimeException: Unable to start activity ComponentInfo{reboot.grouper/reboot.grouper.UI.Lists}: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                      at android.app.ActivityThread.-wrap11(ActivityThread.java)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                      at android.os.Handler.dispatchMessage(Handler.java:102)
                      at android.os.Looper.loop(Looper.java:148)
                      at android.app.ActivityThread.main(ActivityThread.java:5417)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                   Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
                      at co.chatsdk.core.session.Configuration$Builder.firebase(Configuration.java:158)
                      at co.chatsdk.core.session.Configuration$Builder.configureFromManifest(Configuration.java:371)
                      at co.chatsdk.core.session.Configuration$Builder.<init>(Configuration.java:116)
                      at reboot.grouper.UI.Lists.onCreate(Lists.java:101)
                      at android.app.Activity.performCreate(Activity.java:6237)
                      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                      at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                      at android.os.Handler.dispatchMessage(Handler.java:102) 
                      at android.os.Looper.loop(Looper.java:148) 
                      at android.app.ActivityThread.main(ActivityThread.java:5417) 
                      at java.lang.reflect.Method.invoke(Native Method) 
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

SimpleAesthetics avatar Nov 28 '17 21:11 SimpleAesthetics

I am trying to create a single chat instance using this

NM.publicThread().createPublicThreadWithName(threadName)
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe(new BiConsumer<Thread, Throwable>() {
    @Override
    public void accept(Thread thread, Throwable throwable) throws Exception {
        if(throwable == null) {
            InterfaceManager.shared().a.startChatActivityForID(getContext(), thread.getEntityID());
        }
        else {
          // Handle error
	    }
});

so do still have to initialize the sdk in oncreate() to do this

SimpleAesthetics avatar Nov 28 '17 21:11 SimpleAesthetics

I think you need to add this to your App manifest:

<meta-data android:name="firebase_root_path" android:value="@string/firebase_root_path" />

To your strings file:

<string name="firebase_root_path"></string>

This is a bug which will be fixed in tomorrows release.

bensmiley avatar Nov 28 '17 21:11 bensmiley

You always have to initialize the Chat SDK and authenticate the user before you use any other Chat SDK functions. Important functions are performed during setup so it can't be skipped.

bensmiley avatar Nov 28 '17 21:11 bensmiley

still getting the same error on

Configuration.Builder builder = new Configuration.Builder(context);

SimpleAesthetics avatar Nov 28 '17 21:11 SimpleAesthetics

Can you try this again with the latest version - 4.0.6?

bensmiley avatar Dec 01 '17 10:12 bensmiley

Closing due to inactivity.

bensmiley avatar Dec 13 '17 17:12 bensmiley