question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

help with chat skd set up, null error on Configuration.java of chat_sdk_core

See original GitHub issue

I followed the steps on readme, i configure using android manifest and but when i try to run the app this error is thrown

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.hernan.ingeviajes, PID: 24615 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.hernan.ingeviajes/com.hernan.ingeviajes.MainActivity}: 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:2817) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6541) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 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:163) at co.chatsdk.core.session.Configuration$Builder.configureFromManifest(Configuration.java:371) at co.chatsdk.core.session.Configuration$Builder.<init>(Configuration.java:121) at com.hernan.ingeviajes.MainActivity.onCreate(MainActivity.java:27) at android.app.Activity.performCreate(Activity.java:6975) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)  at android.app.ActivityThread.-wrap11(Unknown Source:0)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)  at android.os.Handler.dispatchMessage(Handler.java:105)  at android.os.Looper.loop(Looper.java:164)  at android.app.ActivityThread.main(ActivityThread.java:6541)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)  E/UncaughtException: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.hernan.ingeviajes/com.hernan.ingeviajes.MainActivity}: 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:2817) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6541) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 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:163) at co.chatsdk.core.session.Configuration$Builder.configureFromManifest(Configuration.java:371) at co.chatsdk.core.session.Configuration$Builder.<init>(Configuration.java:121) at com.hernan.ingeviajes.MainActivity.onCreate(MainActivity.java:27) at android.app.Activity.performCreate(Activity.java:6975) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)  at android.app.ActivityThread.-wrap11(Unknown Source:0)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)  at android.os.Handler.dispatchMessage(Handler.java:105)  at android.os.Looper.loop(Looper.java:164)  at android.app.ActivityThread.main(ActivityThread.java:6541)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 

when i debug, on this method

public Builder firebase (String url, String rootPath, String storageUrl, String cloudMessagingServerKey) {
            if(!url.substring(url.length() - 1).equals('/')) {
                url += "/";
            }
            if(!rootPath.substring(rootPath.length() - 1).equals('/')) {
                rootPath += "/";
            }
            config.firebaseUrl = url;
            config.firebaseRootPath = rootPath;
            config.firebaseStorageUrl = storageUrl;
            config.firebaseCloudMessagingServerKey = cloudMessagingServerKey;
            return this;
        }

the url and other parameters are null but i don’t know why, im new at android development, any help please? also the facebook app id is correct on my firebase console but an error is thrown:

A valid Facebook app id must be set in the AndroidManifest.xml or set by calling FacebookSdk.setApplicationId before initializing the sdk.

This is my manifest file:


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.hernan.ingeviajes">
    <meta-data android:name="firebase_url" android:value="@string/firebase_url" />
    <meta-data android:name="firebase_root_path" android:value="@string/firebase_root_path" />
    <meta-data android:name="firebase_storage_url" android:value="@string/firebase_storage_url" />
    <meta-data android:name="com.google.android.geo.API_KEY" android:value="@string/google_maps_api_key"/>
    <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
    <meta-data android:name="cloud_messaging_server_key" android:value="@string/firebase_cloud_messaging_server_key" />
    <uses-permission android:name="android.permission.INTERNET" />
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
       >
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="co.chatsdk.ui.login.LoginActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
bensmileycommented, Nov 13, 2017

The problem is that your setup code isn’t being called. You need to add this code to either your main activity (if you call a different activity before starting the Chat SDK) or in your Application onCreate method.

If you don’t have that method you can create it by making a new class that inherits from Application.

public class MainApp extends Application {

    @Override
    public void onCreate() {
        super.onCreate();

        Context context = getApplicationContext();

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

        // Initialize the Chat SDK
        ChatSDK.initialize(builder.build());

        UserInterfaceModule.activate(context);
        FirebaseModule.activate();
        FirebaseFileStorageModule.activate();

    }
}

Then registering this class in the AndroidManifest.xml file by adding the android:name attribute to the application tag:

android:name=".MainApp"
1reaction
lHernancommented, Nov 5, 2017

Thanks Steven, it works but now i have the following error:

11-05 16:24:54.031 5851-5851/com.hernan.ingeviajes E/AndroidRuntime: FATAL EXCEPTION: main
                                                                     Process: com.hernan.ingeviajes, PID: 5851
                                                                     java.lang.RuntimeException: Unable to start activity ComponentInfo{com.hernan.ingeviajes/co.chatsdk.ui.login.LoginActivity}: java.lang.NullPointerException: Attempt to read from field 'co.chatsdk.core.handlers.AuthenticationHandler co.chatsdk.core.base.BaseNetworkAdapter.auth' on a null object reference
                                                                         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
                                                                         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
                                                                         at android.app.ActivityThread.-wrap11(Unknown Source:0)
                                                                         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
                                                                         at android.os.Handler.dispatchMessage(Handler.java:105)
                                                                         at android.os.Looper.loop(Looper.java:164)
                                                                         at android.app.ActivityThread.main(ActivityThread.java:6541)
                                                                         at java.lang.reflect.Method.invoke(Native Method)
                                                                         at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
                                                                         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
                                                                      Caused by: java.lang.NullPointerException: Attempt to read from field 'co.chatsdk.core.handlers.AuthenticationHandler co.chatsdk.core.base.BaseNetworkAdapter.auth' on a null object reference
                                                                         at co.chatsdk.core.session.NM.auth(NM.java:37)
                                                                         at co.chatsdk.ui.login.LoginActivity.initViews(LoginActivity.java:99)
                                                                         at co.chatsdk.ui.login.LoginActivity.onCreate(LoginActivity.java:76)
                                                                         at android.app.Activity.performCreate(Activity.java:6975)
                                                                         at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
                                                                         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
                                                                         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892) 
                                                                         at android.app.ActivityThread.-wrap11(Unknown Source:0) 
                                                                         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593) 
                                                                         at android.os.Handler.dispatchMessage(Handler.java:105) 
                                                                         at android.os.Looper.loop(Looper.java:164) 
                                                                         at android.app.ActivityThread.main(ActivityThread.java:6541) 
                                                                         at java.lang.reflect.Method.invoke(Native Method) 
                                                                         at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 
                                                                         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 
11-05 16:24:54.032 5851-5851/com.hernan.ingeviajes E/UncaughtException: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.hernan.ingeviajes/co.chatsdk.ui.login.LoginActivity}: java.lang.NullPointerException: Attempt to read from field 'co.chatsdk.core.handlers.AuthenticationHandler co.chatsdk.core.base.BaseNetworkAdapter.auth' on a null object reference
                                                                            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
                                                                            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
                                                                            at android.app.ActivityThread.-wrap11(Unknown Source:0)
                                                                            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
                                                                            at android.os.Handler.dispatchMessage(Handler.java:105)
                                                                            at android.os.Looper.loop(Looper.java:164)
                                                                            at android.app.ActivityThread.main(ActivityThread.java:6541)
                                                                            at java.lang.reflect.Method.invoke(Native Method)
                                                                            at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
                                                                            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
                                                                         Caused by: java.lang.NullPointerException: Attempt to read from field 'co.chatsdk.core.handlers.AuthenticationHandler co.chatsdk.core.base.BaseNetworkAdapter.auth' on a null object reference
                                                                            at co.chatsdk.core.session.NM.auth(NM.java:37)
                                                                            at co.chatsdk.ui.login.LoginActivity.initViews(LoginActivity.java:99)
                                                                            at co.chatsdk.ui.login.LoginActivity.onCreate(LoginActivity.java:76)
                                                                            at android.app.Activity.performCreate(Activity.java:6975)
                                                                            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
                                                                            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
                                                                            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892) 
                                                                            at android.app.ActivityThread.-wrap11(Unknown Source:0) 
                                                                            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593) 
                                                                            at android.os.Handler.dispatchMessage(Handler.java:105) 
                                                                            at android.os.Looper.loop(Looper.java:164) 
                                                                            at android.app.ActivityThread.main(ActivityThread.java:6541) 
                                                                            at java.lang.reflect.Method.invoke(Native Method) 
                                                                            at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 
                                                                            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 

i guess is something about facebook login is wrong, but i disabled that option on my main activity.

        builder.facebookLoginEnabled(false);
        builder.twitterLoginEnabled(false);

Still get the same error, any suggestion?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Quick Setup: Chat in the Service SDK - Salesforce Developers
Quick Setup: Chat in the Service SDK. To add Chat to your Android app, create a configuration object that points to your org...
Read more >
Null object reference while get last messages from channel ...
So it's about getting,. java.lang.NullPointerException. while using Twilio programable chat SDK in Android.
Read more >
Chat - Genesys Documentation
You can use the Web Media Platform SDK to write Java or .NET applications that use the Genesys Web Media Server's chat, email...
Read more >
Guest Chat Client - Java - Genesys Cloud Developer Center
This requires Java 8 support in Android Studio (2.4 Preview 6 or later). ... Configuration; import com.mypurecloud.sdk.v2.guest.api.
Read more >
Chat (Chat SDK v2 - v320)
Sets the default configuration used when starting chats from this SDK. void, setIdentity(JwtAuthenticator jwtAuthenticator). Sets up the Chat SDK to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found