chat-sdk / chat-sdk-android

Chat SDK Android - Open Source Mobile Messenger

Home Page:https://chatsdk.co

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sdk.chat.core.base.BaseNetworkAdapter.auth on a null object reference

santho5 opened this issue · comments

  1. Is the bug present in the demo Chat SDK project?

  2. What modifications have you made to the Chat SDK? nothing

  3. Android Version: androind 4.1 jellybean

  4. Steps taken to reproduce the problem: done exactly as per the video demo.no changes made

  5. Expected result:

  6. Actual result:

  7. Comments:

I ahve done exactly as per the video tutorial and using ChatSDKFirebase.quickStart

//////////////////////////////////////////////////////

2021-01-14 23:46:55.395 13268-13268/com.xxxx.yyyyy E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.advitech.namaste, PID: 13268
    java.lang.RuntimeException: Unable to resume activity {com.advitech.namaste/sdk.chat.ui.activities.SplashScreenActivity}: java.lang.NullPointerException: Attempt to read from field 'sdk.chat.core.handlers.AuthenticationHandler sdk.chat.core.base.BaseNetworkAdapter.auth' on a null object reference
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4444)
        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4476)
        at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52)
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
     Caused by: java.lang.NullPointerException: Attempt to read from field 'sdk.chat.core.handlers.AuthenticationHandler sdk.chat.core.base.BaseNetworkAdapter.auth' on a null object reference
        at sdk.chat.core.session.ChatSDK.auth(ChatSDK.java:281)
        at sdk.chat.ui.activities.SplashScreenActivity.startNextActivity(SplashScreenActivity.java:53)
        at sdk.chat.ui.activities.SplashScreenActivity.onResume(SplashScreenActivity.java:49)
        at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1456)
        at android.app.Activity.performResume(Activity.java:8135)
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4434)
        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4476) 
        at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52) 
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:223) 
        at android.app.ActivityThread.main(ActivityThread.java:7656) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) 

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

My MainApp.java is

package com.xxxxx.yyyyy;

import android.app.Application;
import android.content.Context;

import sdk.chat.app.firebase.ChatSDKFirebase;
import sdk.chat.core.session.ChatSDK;

public class MainApp extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        try {
            ChatSDKFirebase.quickStart(this, "root", "abcde", true );
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}

/////////////////////////////////////////////////////////

the firebase database is as follows

XXXXX-dddd-eeee-default-rtdb
Test: 123
root
branch
subbranch: 1

What is the rootPath value is should use?

why the error comes when runnin the app and crashing?

pleae help...

Is an error being caught here?

catch (Exception e) {
e.printStackTrace();
}

no the error is not catching there e.printStackTrace()

please see the log at verbose mode...

2021-01-15 09:16:37.411 15561-15561/com.advitech.namaste W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:106)
2021-01-15 09:16:37.411 15561-15561/com.advitech.namaste W/System.err:     at android.os.Looper.loop(Looper.java:223)
2021-01-15 09:16:37.411 15561-15561/com.advitech.namaste W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:7656)
2021-01-15 09:16:37.412 15561-15561/com.advitech.namaste W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
2021-01-15 09:16:37.412 15561-15561/com.advitech.namaste W/System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
2021-01-15 09:16:37.412 15561-15561/com.advitech.namaste W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
2021-01-15 09:16:37.413 15561-15561/com.advitech.namaste W/System.err: Caused by: com.google.firebase.database.DatabaseException: Failed to get FirebaseDatabase instance: Specify DatabaseURL within FirebaseApp or from your getInstance() call.
2021-01-15 09:16:37.413 15561-15561/com.advitech.namaste W/System.err:     at com.google.firebase.database.FirebaseDatabase.getInstance(com.google.firebase:firebase-database@@19.3.0:97)
2021-01-15 09:16:37.413 15561-15561/com.advitech.namaste W/System.err:     at com.google.firebase.database.FirebaseDatabase.getInstance(com.google.firebase:firebase-database@@19.3.0:83)
2021-01-15 09:16:37.413 15561-15561/com.advitech.namaste W/System.err:     at sdk.chat.firebase.adapter.FirebaseCoreHandler.database(FirebaseCoreHandler.java:151)
2021-01-15 09:16:37.413 15561-15561/com.advitech.namaste W/System.err:     at sdk.chat.firebase.adapter.FirebaseCoreHandler.<init>(FirebaseCoreHandler.java:27)
2021-01-15 09:16:37.413 15561-15561/com.advitech.namaste W/System.err:     at sdk.chat.firebase.adapter.FirebaseNetworkAdapter.<init>(FirebaseNetworkAdapter.java:13)
2021-01-15 09:16:37.413 15561-15561/com.advitech.namaste W/System.err: 	... 16 more
2021-01-15 09:16:37.431 15561-15619/com.advitech.namaste D/libEGL: loaded /vendor/lib/egl/libEGL_emulation.so
2021-01-15 09:16:37.436 15561-15619/com.advitech.namaste D/libEGL: loaded /vendor/lib/egl/libGLESv1_CM_emulation.so
2021-01-15 09:16:37.442 15561-15619/com.advitech.namaste D/libEGL: loaded /vendor/lib/egl/libGLESv2_emulation.so
2021-01-15 09:16:37.522 15561-15561/com.advitech.namaste W/dvitech.namast: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
2021-01-15 09:16:37.522 15561-15561/com.advitech.namaste W/dvitech.namast: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
2021-01-15 09:16:37.615 15561-15561/com.advitech.namaste D/AndroidRuntime: Shutting down VM
2021-01-15 09:16:37.616 15561-15561/com.advitech.namaste E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.advitech.namaste, PID: 15561
    java.lang.RuntimeException: Unable to resume activity {com.advitech.namaste/sdk.chat.ui.activities.SplashScreenActivity}: java.lang.NullPointerException: Attempt to read from field 'sdk.chat.core.handlers.AuthenticationHandler sdk.chat.core.base.BaseNetworkAdapter.auth' on a null object reference
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4444)
        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4476)
        at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52)
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
     Caused by: java.lang.NullPointerException: Attempt to read from field 'sdk.chat.core.handlers.AuthenticationHandler sdk.chat.core.base.BaseNetworkAdapter.auth' on a null object reference
        at sdk.chat.core.session.ChatSDK.auth(ChatSDK.java:281)
        at sdk.chat.ui.activities.SplashScreenActivity.startNextActivity(SplashScreenActivity.java:53)
        at sdk.chat.ui.activities.SplashScreenActivity.onResume(SplashScreenActivity.java:49)
        at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1456)
        at android.app.Activity.performResume(Activity.java:8135)
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4434)
        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4476) 
        at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52) 
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:223) 
        at android.app.ActivityThread.main(ActivityThread.java:7656) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) 
2021-01-15 09:17:07.243 15561-15604/com.advitech.namaste W/FirebaseInstanceId: Token retrieval failed: SERVICE_NOT_AVAILABLE. Will retry token retrieval
2021-01-15 09:18:07.328 15561-15604/com.advitech.namaste W/FirebaseInstanceId: Token retrieval failed: SERVICE_NOT_AVAILABLE. Will retry token retrieval

is it a firebase related issue?... token retrieval failed...

java.lang.NullPointerException: Attempt to read from field 'sdk.chat.core.handlers.AuthenticationHandler sdk.chat.core.base.BaseNetworkAdapter.auth' on a null object reference

This usually happens if the Chat SDK initialization has not completed properly. That can happen if you are not setting up the Chat SDK in the main application onCreate method or if there is some exception that happens during initialization.

Closing due to inactivity.