help with chat skd set up, null error on Configuration.java of chat_sdk_core
See original GitHub issueI 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:
- Created 6 years ago
- Comments:7 (2 by maintainers)
Top GitHub Comments
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.
Then registering this class in the
AndroidManifest.xml
file by adding theandroid:name
attribute to theapplication
tag:Thanks Steven, it works but now i have the following error:
i guess is something about facebook login is wrong, but i disabled that option on my main activity.
Still get the same error, any suggestion?