What cause the exception ' java.lang.RuntimeException: Failed to call observer method'? - android

I am writing code to fetch data from a firebase database:
private void displayMessages(){
//Suppose you want to retrieve "chats" in your Firebase DB:
DatabaseReference ref=FirebaseDatabase.getInstance().getReference(Constants.USERS_CHAT).child(chatId);
Log.d(TAG,"Inside query"+ref);
ref.addListenerForSingleValueEvent(new ValueEventListener(){
#Override
public void onDataChange(DataSnapshot dataSnapshot){
Log.d(TAG,"Inside query Inside onDataChange");
if(dataSnapshot.exists()) {
queryforDisplayMessages=mDbRefusers_chat.child(chatId);
}else{
queryforDisplayMessages=mDbRefusers_chat.child(revchatId);
}
}
#Override
public void onCancelled(DatabaseError databaseError) {
}
});
But when running it, I get the following exception:
Process: com.iworld.daxi, PID: 20438
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.iworld.daxi/com.iworld.daxi.UserChatActivity}:
java.lang.RuntimeException: Failed to call observer method
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2946)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3046)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1688)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6809)
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.RuntimeException: Failed to call observer method
at android.arch.lifecycle.ClassesInfoCache$MethodReference.invokeCallback(ClassesInfoCache.java:225)
at android.arch.lifecycle.ClassesInfoCache$CallbackInfo.invokeMethodsForEvent(ClassesInfoCache.java:193)
at android.arch.lifecycle.ClassesInfoCache$CallbackInfo.invokeCallbacks(ClassesInfoCache.java:184)
at android.arch.lifecycle.ReflectiveGenericLifecycleObserver.onStateChanged(ReflectiveGenericLifecycleObserver.java:36)
at android.arch.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:354)
at android.arch.lifecycle.LifecycleRegistry.forwardPass(LifecycleRegistry.java:292)
at android.arch.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.java:332)
at android.arch.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.java:137)
at android.arch.lifecycle.LifecycleRegistry.handleLifecycleEvent(LifecycleRegistry.java:123)
at android.arch.lifecycle.ReportFragment.dispatch(ReportFragment.java:121)
at android.arch.lifecycle.ReportFragment.onStart(ReportFragment.java:81)
at android.app.Fragment.performStart(Fragment.java:2637)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1312)
at android.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1549)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1611)
at android.app.FragmentManagerImpl.dispatchMoveToState(FragmentManager.java:3039)
at android.app.FragmentManagerImpl.dispatchStart(FragmentManager.java:2996)
at android.app.FragmentController.dispatchStart(FragmentController.java:189)
at android.app.Activity.performStart(Activity.java:7021)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2909)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3046) 
at android.app.ActivityThread.-wrap11(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1688) 
at android.os.Handler.dispatchMessage(Handler.java:105) 
at android.os.Looper.loop(Looper.java:164) 
at android.app.ActivityThread.main(ActivityThread.java:6809) 
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 'com.google.firebase.database.ChildEventListener com.google.firebase.database.Query.addChildEventListener(com.google.firebase.database.ChildEventListener)' on a null object reference
at com.firebase.ui.database.FirebaseArray.onCreate(FirebaseArray.java:53)
at com.firebase.ui.common.BaseObservableSnapshotArray.addChangeEventListener(BaseObservableSnapshotArray.java:97)
at com.firebase.ui.database.FirebaseListAdapter.startListening(FirebaseListAdapter.java:48)
at java.lang.reflect.Method.invoke(Native Method)
at android.arch.lifecycle.ClassesInfoCache$MethodReference.invokeCallback(ClassesInfoCache.java:215)
at android.arch.lifecycle.ClassesInfoCache$CallbackInfo.invokeMethodsForEvent(ClassesInfoCache.java:193) 
at android.arch.lifecycle.ClassesInfoCache$CallbackInfo.invokeCallbacks(ClassesInfoCache.java:184) 
at android.arch.lifecycle.ReflectiveGenericLifecycleObserver.onStateChanged(ReflectiveGenericLifecycleObserver.java:36) 
at android.arch.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:354) 
at android.arch.lifecycle.LifecycleRegistry.forwardPass(LifecycleRegistry.java:292) 
at android.arch.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.java:332) 
at android.arch.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.java:137) 
at android.arch.lifecycle.LifecycleRegistry.handleLifecycleEvent(LifecycleRegistry.java:123) 
at android.arch.lifecycle.ReportFragment.dispatch(ReportFragment.java:121) 
at android.arch.lifecycle.ReportFragment.onStart(ReportFragment.java:81) 
at android.app.Fragment.performStart(Fragment.java:2637) 
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1312) 
at android.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1549) 
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1611) 
at android.app.FragmentManagerImpl.dispatchMoveToState(FragmentManager.java:3039) 
at android.app.FragmentManagerImpl.dispatchStart(FragmentManager.java:2996) 
at android.app.FragmentController.dispatchStart(FragmentController.java:189) 
at android.app.Activity.performStart(Activity.java:7021) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2909) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3046) 
at android.app.ActivityThread.-wrap11(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1688) 
at android.os.Handler.dispatchMessage(Handler.java:105) 
at android.os.Looper.loop(Looper.java:164) 
at android.app.ActivityThread.main(ActivityThread.java:6809) 
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) 
03-08 10:22:40.020 20438-20438/com.iworld.daxi D/AppTracker: App Event: crash
I have also observed that the onDataChange() method is not getting triggered.

Related

Passing object parameter to extended AsyncTask class

GoodDay everybody.
I wrote a class which extends AsyncTask.
public class InitTransaction extends AsyncTask<TransactionParameters, Void, String> {
#Override
protected String doInBackground(TransactionParameters... params) {
// I do some stuff here
return result;
}
#Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
// I do some more stuff
}
}
The class is called with:
TransactionParameters transParams = new TransactionParameters(param1, param2);
InitTransaction initTransaction = new InitTransaction();
initTransaction.execute(transParams);
The problem is that i get an error while passing the object to the task:
[![No method?][1]][1]
Anybody knows where the problem may be?
EDIT
Fixed that problem now I have another one.
As soon as I execute initTransaction.execute(transParams); boom!
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.infovision.elcam_02, PID: 17443
java.lang.IllegalStateException: Could not execute method for android:onClick
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:389)
at android.view.View.performClick(View.java:6600)
at android.view.View.performClickInternal(View.java:6577)
at android.view.View.access$3100(View.java:781)
at android.view.View$PerformClick.run(View.java:25912)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6923)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:870)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:384)
at android.view.View.performClick(View.java:6600) 
at android.view.View.performClickInternal(View.java:6577) 
at android.view.View.access$3100(View.java:781) 
at android.view.View$PerformClick.run(View.java:25912) 
at android.os.Handler.handleCallback(Handler.java:873) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:193) 
at android.app.ActivityThread.main(ActivityThread.java:6923) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:870) 
Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?
at android.view.ViewRootImpl.setView(ViewRootImpl.java:828)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:356)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93)
at android.app.Dialog.show(Dialog.java:329)
at com.infovision.elcam_02.MainActivity$InitTransaction.onPreExecute(MainActivity.java:242)
at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:648)
at android.os.AsyncTask.execute(AsyncTask.java:595)
at com.infovision.elcam_02.MainActivity.scanCode(MainActivity.java:133)
at java.lang.reflect.Method.invoke(Native Method) 
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:384) 
at android.view.View.performClick(View.java:6600) 
at android.view.View.performClickInternal(View.java:6577) 
at android.view.View.access$3100(View.java:781) 
at android.view.View$PerformClick.run(View.java:25912) 
at android.os.Handler.handleCallback(Handler.java:873) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:193) 
at android.app.ActivityThread.main(ActivityThread.java:6923) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:870) 

fb login api logout error when i use my own button to logout and want to open my Mainactivity

Iam using facebook login api to login after sucessfully logging in now i want to logout my user not by facebook login button bu by my own button
by using this code
button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
LoginManager.getInstance().logOut();
Intent i=new Intent(Mapsstuff.this,Login.class);
startActivity(I);
}
});
After i execute it my app started crashing now i remove this code but still my app is crashing and this is showing in my logcat
10-22 19:00:38.806 10964-10964/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.ab.cleano, PID: 10964
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.ab.cleano/com.example.ab.cleano.Login}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.facebook.AccessToken.getUserId()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2946)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3046)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1688)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6798)
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 'java.lang.String com.facebook.AccessToken.getUserId()' on a null object reference
at com.example.ab.cleano.Login.onCreate(Login.java:168)
at android.app.Activity.performCreate(Activity.java:7003)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1230)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2899)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3046) 
at android.app.ActivityThread.-wrap11(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1688) 
at android.os.Handler.dispatchMessage(Handler.java:105) 
at android.os.Looper.loop(Looper.java:164) 
at android.app.ActivityThread.main(ActivityThread.java:6798) 
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) 
How to solve it please help

React-Native: AsyncStorage crashes Android app

I'm writing an App for Android and iOS using react-native.
The iOS version works perfectly but the Android version crashes every time it try to calls a AsyncStorage function.
When my App launches, it checks if there are some user-information stored on the device. It uses this function here:
static async getActiveUser() {
return null;
try {
let value = await AsyncStorage.getItem('#UserStore:activeUser');
if (value !== null){
return JSON.parse(value);
} else {
return null;
}
} catch (error) {
console.log(error);
}
}
As I said before, the iOS version runs perfectly. When I run this code on Android, it crashes at this line:
let value = await AsyncStorage.getItem('#UserStore:activeUser');
The function getActiveUser() gets called inside the componentDidMount function.
I'm searching for hours on a solution!! Can someone help? Thanks a lot!
EDIT:
Error-Log:
07-16 13:16:49.082 7154-7205/com.mblum.cvjm E/unknown:ViewManager: Error while updating prop color
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Double
at com.facebook.react.bridge.ReadableNativeMap.getInt(ReadableNativeMap.java:159)
at com.facebook.react.uimanager.ReactStylesDiffMap.getInt(ReactStylesDiffMap.java:68)
at com.facebook.react.uimanager.ViewManagersPropertyCache$BoxedIntPropSetter.extractProperty(ViewManagersPropertyCache.java:275)
at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateShadowNodeProp(ViewManagersPropertyCache.java:101)
at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackShadowNodeSetter.setProperty(ViewManagerPropertyUpdater.java:154)
at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(ViewManagerPropertyUpdater.java:58)
at com.facebook.react.uimanager.ReactShadowNodeImpl.updateProperties(ReactShadowNodeImpl.java:298)
at com.facebook.react.uimanager.UIImplementation.createView(UIImplementation.java:289)
at com.facebook.react.uimanager.UIManagerModule.createView(UIManagerModule.java:364)
at java.lang.reflect.Method.invoke(Native Method)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:374)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:162)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:164)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194)
at java.lang.Thread.run(Thread.java:764)
07-16 13:16:49.085 7154-7205/com.mblum.cvjm E/unknown:ReactNative: Exception in native call
com.facebook.react.bridge.JSApplicationIllegalArgumentException: Error while updating property 'color' in shadow node of type: AndroidTextInput
at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateShadowNodeProp(ViewManagersPropertyCache.java:113)
at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackShadowNodeSetter.setProperty(ViewManagerPropertyUpdater.java:154)
at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(ViewManagerPropertyUpdater.java:58)
at com.facebook.react.uimanager.ReactShadowNodeImpl.updateProperties(ReactShadowNodeImpl.java:298)
at com.facebook.react.uimanager.UIImplementation.createView(UIImplementation.java:289)
at com.facebook.react.uimanager.UIManagerModule.createView(UIManagerModule.java:364)
at java.lang.reflect.Method.invoke(Native Method)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:374)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:162)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:164)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Double
at com.facebook.react.bridge.ReadableNativeMap.getInt(ReadableNativeMap.java:159)
at com.facebook.react.uimanager.ReactStylesDiffMap.getInt(ReactStylesDiffMap.java:68)
at com.facebook.react.uimanager.ViewManagersPropertyCache$BoxedIntPropSetter.extractProperty(ViewManagersPropertyCache.java:275)
at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateShadowNodeProp(ViewManagersPropertyCache.java:101)
at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackShadowNodeSetter.setProperty(ViewManagerPropertyUpdater.java:154) 
at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(ViewManagerPropertyUpdater.java:58) 
at com.facebook.react.uimanager.ReactShadowNodeImpl.updateProperties(ReactShadowNodeImpl.java:298) 
at com.facebook.react.uimanager.UIImplementation.createView(UIImplementation.java:289) 
at com.facebook.react.uimanager.UIManagerModule.createView(UIManagerModule.java:364) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:374) 
at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:162) 
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) 
at android.os.Handler.handleCallback(Handler.java:789) 
at android.os.Handler.dispatchMessage(Handler.java:98) 
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31) 
at android.os.Looper.loop(Looper.java:164) 
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194) 
at java.lang.Thread.run(Thread.java:764) 
07-16 13:16:49.098 7154-7205/com.mblum.cvjm E/unknown:ViewManager: Error while updating prop color
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Double
at com.facebook.react.bridge.ReadableNativeMap.getInt(ReadableNativeMap.java:159)
at com.facebook.react.uimanager.ReactStylesDiffMap.getInt(ReactStylesDiffMap.java:68)
at com.facebook.react.uimanager.ViewManagersPropertyCache$BoxedIntPropSetter.extractProperty(ViewManagersPropertyCache.java:275)
at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateShadowNodeProp(ViewManagersPropertyCache.java:101)
at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackShadowNodeSetter.setProperty(ViewManagerPropertyUpdater.java:154)
at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(ViewManagerPropertyUpdater.java:58)
at com.facebook.react.uimanager.ReactShadowNodeImpl.updateProperties(ReactShadowNodeImpl.java:298)
at com.facebook.react.uimanager.UIImplementation.createView(UIImplementation.java:289)
at com.facebook.react.uimanager.UIManagerModule.createView(UIManagerModule.java:364)
at java.lang.reflect.Method.invoke(Native Method)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:374)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:162)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:164)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194)
at java.lang.Thread.run(Thread.java:764)
07-16 13:16:49.110 7154-7205/com.mblum.cvjm E/unknown:ReactNative: Exception in native call
com.facebook.react.bridge.JSApplicationIllegalArgumentException: Error while updating property 'color' in shadow node of type: AndroidTextInput
at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateShadowNodeProp(ViewManagersPropertyCache.java:113)
at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackShadowNodeSetter.setProperty(ViewManagerPropertyUpdater.java:154)
at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(ViewManagerPropertyUpdater.java:58)
at com.facebook.react.uimanager.ReactShadowNodeImpl.updateProperties(ReactShadowNodeImpl.java:298)
at com.facebook.react.uimanager.UIImplementation.createView(UIImplementation.java:289)
at com.facebook.react.uimanager.UIManagerModule.createView(UIManagerModule.java:364)
at java.lang.reflect.Method.invoke(Native Method)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:374)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:162)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:164)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Double
at com.facebook.react.bridge.ReadableNativeMap.getInt(ReadableNativeMap.java:159)
at com.facebook.react.uimanager.ReactStylesDiffMap.getInt(ReactStylesDiffMap.java:68)
at com.facebook.react.uimanager.ViewManagersPropertyCache$BoxedIntPropSetter.extractProperty(ViewManagersPropertyCache.java:275)
at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateShadowNodeProp(ViewManagersPropertyCache.java:101)
at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackShadowNodeSetter.setProperty(ViewManagerPropertyUpdater.java:154) 
at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(ViewManagerPropertyUpdater.java:58) 
at com.facebook.react.uimanager.ReactShadowNodeImpl.updateProperties(ReactShadowNodeImpl.java:298) 
at com.facebook.react.uimanager.UIImplementation.createView(UIImplementation.java:289) 
at com.facebook.react.uimanager.UIManagerModule.createView(UIManagerModule.java:364) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:374) 
at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:162) 
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) 
at android.os.Handler.handleCallback(Handler.java:789) 
at android.os.Handler.dispatchMessage(Handler.java:98) 
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31) 
at android.os.Looper.loop(Looper.java:164) 
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194) 
at java.lang.Thread.run(Thread.java:764) 
07-16 13:16:49.205 7154-7154/com.mblum.cvjm D/ReactNative: CatalystInstanceImpl.destroy() start
CatalystInstanceImpl.destroy() start
07-16 13:16:49.220 7154-7154/com.mblum.cvjm W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.text.ReactTextViewManager
07-16 13:16:49.241 7154-7154/com.mblum.cvjm W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.view.ReactViewManager
07-16 13:16:49.262 7154-7184/com.mblum.cvjm W/ContextImpl: Failed to ensure /dev/null/Android/data/com.mblum.cvjm/cache: 400
07-16 13:16:49.276 7154-7154/com.mblum.cvjm D/AndroidRuntime: Shutting down VM
07-16 13:16:49.278 7154-7154/com.mblum.cvjm E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mblum.cvjm, PID: 7154
java.lang.RuntimeException: com.facebook.react.uimanager.IllegalViewOperationException: Trying to add unknown view tag: 20
detail: View tag:32
children(4): [
10,13,16,18,
],
viewsToAdd(1): [
[4,20],
],
at com.facebook.react.bridge.ReactContext.handleException(ReactContext.java:313)
at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:33)
at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:136)
at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:107)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:909)
at android.view.Choreographer.doCallbacks(Choreographer.java:723)
at android.view.Choreographer.doFrame(Choreographer.java:655)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
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: com.facebook.react.uimanager.IllegalViewOperationException: Trying to add unknown view tag: 20
detail: View tag:32
children(4): [
10,13,16,18,
],
viewsToAdd(1): [
[4,20],
],
at com.facebook.react.uimanager.NativeViewHierarchyManager.manageChildren(NativeViewHierarchyManager.java:394)
at com.facebook.react.uimanager.UIViewOperationQueue$ManageChildrenOperation.execute(UIViewOperationQueue.java:180)
at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:822)
at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:929)
at com.facebook.react.uimanager.UIViewOperationQueue.access$2100(UIViewOperationQueue.java:47)
at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:989)
at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:31)
... 13 more
your log,
07-16 13:16:49.098 7154-7205/com.mblum.cvjm E/unknown:ViewManager: Error while updating prop color
It is not a problem in your AsyncStorage as the log clearly states that.
some tips:
If you ever think AsyncStorage is not responding well, it usually means you have a wrong data type in there. So always try AsyncStorage.setItem(JSON.stringify('token'));
(just for debugging purposes)

android button causing crash [duplicate]

This question already has answers here:
What is a NullPointerException, and how do I fix it?
(12 answers)
Closed 4 years ago.
I am trying to pass login details to another class so that it can be used to login on my MySQL db (using php) but it is crashing giving me the exception: java.lang.IllegalStateException: Could not execute method for android:onClick
stack trace: {StackTraceElement[0]#5692}
658 10752-10752/uk.ac.abertay.contactslist E/AndroidRuntime: FATAL EXCEPTION: main
Process: uk.ac.abertay.contactslist, PID: 10752
java.lang.IllegalStateException: Could not execute method for android:onClick
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:293)
at android.view.View.performClick(View.java:6294)
at android.view.View$PerformClick.run(View.java:24770)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)
at android.view.View.performClick(View.java:6294) 
at android.view.View$PerformClick.run(View.java:24770) 
at android.os.Handler.handleCallback(Handler.java:790) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:164) 
at android.app.ActivityThread.main(ActivityThread.java:6494) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void uk.ac.abertay.contactslist.Login.Logino(uk.ac.abertay.contactslist.LoginDetails)' on a null object reference
at uk.ac.abertay.contactslist.LoginActivity.Loginbutton(LoginActivity.java:40)
at java.lang.reflect.Method.invoke(Native Method) 
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288) 
at android.view.View.performClick(View.java:6294) 
at android.view.View$PerformClick.run(View.java:24770) 
at android.os.Handler.handleCallback(Handler.java:790) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:164) 
at android.app.ActivityThread.main(ActivityThread.java:6494) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 
04-26 15:39:34.761 1384-3633/? I/chatty: uid=1041(audioserver) writer identical 8 lines
this is the code for the button
private Login login;
public void Loginbutton(View v) {
/* Get entered fields data. */
String email = field_email.getText().toString();
String password = field_password.getText().toString();
login.Logino(new LoginDetails(email,password));
}
when debugging it will run this and go back to the button and after that it will give the exception and crash
public class LoginDetails {
public String email = "";
public String password = "";
LoginDetails(String e, String p) {
email = e;
password = p;
}
}
this is the code I'm trying to run with the button above
public void Logino(LoginDetails loginDetails) {
LoginTask task = new LoginTask();
task.execute(loginDetails);
}
From your StackTrace
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void uk.ac.abertay.contactslist.Login.Logino(uk.ac.abertay.contactslist.LoginDetails)
The line login.Logino the object login is null, you have to initialize it.
Obs:Please use Java naming conventions with method names starting with low case char.

Android Studio & Firebase... Multiple activities

I have Firebase fully installed into Android Studio, and I've tested it with a couple 1 activity applications, but on the only application with more than one activity, it's not working.
When I try to do the following in my 'Sign up' code:
private void makeStudent(String email, String password) {
Student s = new Student(email, password);
Firebase ref = new Firebase("MYAPP.firebaseio.com/");
//took out my app name
Firebase studentlocation = ref.child("Student");
studentlocation.setValue(s); //this is the line on which I get the error
//also, when I go on my firebase site, it hasn't created the Student
//directory
}
The Firebase page said:
If your Android app has multiple activities, add this code to your Application Class. Otherwise add it in your main activity.
So, I looked around, and this is what I created:
I made a MyApplication.java file, which contained:
import com.firebase.client.Firebase;
public class MyApplication extends android.app.Application {
#Override
public void onCreate() {
super.onCreate();
Firebase.setAndroidContext(this);
}
}
Then I placed the following into AndroidManifest.xml:
android:name=".MyApplication"
Yet, I still receive an error on the exact same line.
How do I fix this Firebase issue? I appreciate any help I can get, please!
ERROR RECEIVED (scroll to the right in the code box):
FATAL EXCEPTION: main
Process: professionalgrader.professionalgrader, PID: 3827
com.firebase.client.FirebaseException: Failed to parse to snapshot
at com.firebase.client.Firebase.setValueInternal(Firebase.java:347)
at com.firebase.client.Firebase.setValue(Firebase.java:238)
at professionalgrader.professionalgrader.SignUp.makeStudent(SignUp.java:94)
at professionalgrader.professionalgrader.SignUp.access$500(SignUp.java:16)
at professionalgrader.professionalgrader.SignUp$1.onClick(SignUp.java:45)
at android.view.View.performClick(View.java:5198)
at android.view.View$PerformClick.run(View.java:21147)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
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.IllegalArgumentException: length=0; index=0 (through reference chain: professionalgrader.professionalgrader.Student["listofTermClasses"])
at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:2615)
at com.fasterxml.jackson.databind.ObjectMapper.convertValue(ObjectMapper.java:2542)
at com.firebase.client.Firebase.setValueInternal(Firebase.java:336)
at com.firebase.client.Firebase.setValue(Firebase.java:238) 
at professionalgrader.professionalgrader.SignUp.makeStudent(SignUp.java:94) 
at professionalgrader.professionalgrader.SignUp.access$500(SignUp.java:16) 
at professionalgrader.professionalgrader.SignUp$1.onClick(SignUp.java:45) 
at android.view.View.performClick(View.java:5198) 
at android.view.View$PerformClick.run(View.java:21147) 
at android.os.Handler.handleCallback(Handler.java:739) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
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: com.fasterxml.jackson.databind.JsonMappingException: length=0; index=0 (through reference chain: professionalgrader.professionalgrader.Student["listofTermClasses"])
at com.fasterxml.jackson.databind.ser.std.StdSerializer.wrapAndThrow(StdSerializer.java:184)
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:605)
at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:142)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:118)
at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:2593)
at com.fasterxml.jackson.databind.ObjectMapper.convertValue(ObjectMapper.java:2542) 
at com.firebase.client.Firebase.setValueInternal(Firebase.java:336) 
at com.firebase.client.Firebase.setValue(Firebase.java:238) 
at professionalgrader.professionalgrader.SignUp.makeStudent(SignUp.java:94) 
at professionalgrader.professionalgrader.SignUp.access$500(SignUp.java:16) 
at professionalgrader.professionalgrader.SignUp$1.onClick(SignUp.java:45) 
at android.view.View.performClick(View.java:5198) 
at android.view.View$PerformClick.run(View.java:21147) 
at android.os.Handler.handleCallback(Handler.java:739) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
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.ArrayIndexOutOfBoundsException: length=0; index=0
at professionalgrader.professionalgrader.Student.getListofTermClasses(Student.java:252)
at java.lang.reflect.Method.invoke(Native Method)
at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.get(BeanPropertyWriter.java:679)
at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:534)
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:597)
at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:142) 
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:118) 
at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:2593) 
at com.fasterxml.jackson.databind.ObjectMapper.convertValue(ObjectMapper.java:2542) 
at com.firebase.client.Firebase.setValueInternal(Firebase.java:336) 
at com.firebase.client.Firebase.setValue(Firebase.java:238) 
at professionalgrader.professionalgrader.SignUp.makeStudent(SignUp.java:94) 
at professionalgrader.professionalgrader.SignUp.access$500(SignUp.java:16) 
at professionalgrader.professionalgrader.SignUp$1.onClick(SignUp.java:45) 
at android.view.View.performClick(View.java:5198) 
at android.view.View$PerformClick.run(View.java:21147) 
at android.os.Handler.handleCallback(Handler.java:739) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
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) 
THE SECOND ERROR:
06-15 04:13:34.902 3089-3089/professionalgrader.professionalgrader E/AndroidRuntime: FATAL EXCEPTION: main
Process: professionalgrader.professionalgrader, PID: 3089
com.firebase.client.FirebaseException: Failed to parse to snapshot
at com.firebase.client.Firebase.setValueInternal(Firebase.java:347)
at com.firebase.client.Firebase.setValue(Firebase.java:238)
at professionalgrader.professionalgrader.SignUp.makeStudent(SignUp.java:94)
at professionalgrader.professionalgrader.SignUp.access$500(SignUp.java:16)
at professionalgrader.professionalgrader.SignUp$1.onClick(SignUp.java:45)
at android.view.View.performClick(View.java:5198)
at android.view.View$PerformClick.run(View.java:21147)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
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.IllegalArgumentException: Attempt to invoke virtual method 'double professionalgrader.professionalgrader.Class.getGPA()' on a null object reference (through reference chain: professionalgrader.professionalgrader.Student["totalGPA"])
at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:2615)
at com.fasterxml.jackson.databind.ObjectMapper.convertValue(ObjectMapper.java:2542)
at com.firebase.client.Firebase.setValueInternal(Firebase.java:336)
at com.firebase.client.Firebase.setValue(Firebase.java:238) 
at professionalgrader.professionalgrader.SignUp.makeStudent(SignUp.java:94) 
at professionalgrader.professionalgrader.SignUp.access$500(SignUp.java:16) 
at professionalgrader.professionalgrader.SignUp$1.onClick(SignUp.java:45) 
at android.view.View.performClick(View.java:5198) 
at android.view.View$PerformClick.run(View.java:21147) 
at android.os.Handler.handleCallback(Handler.java:739) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
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: com.fasterxml.jackson.databind.JsonMappingException: Attempt to invoke virtual method 'double professionalgrader.professionalgrader.Class.getGPA()' on a null object reference (through reference chain: professionalgrader.professionalgrader.Student["totalGPA"])
at com.fasterxml.jackson.databind.ser.std.StdSerializer.wrapAndThrow(StdSerializer.java:184)
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:605)
at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:142)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:118)
at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:2593)
at com.fasterxml.jackson.databind.ObjectMapper.convertValue(ObjectMapper.java:2542) 
at com.firebase.client.Firebase.setValueInternal(Firebase.java:336) 
at com.firebase.client.Firebase.setValue(Firebase.java:238) 
at professionalgrader.professionalgrader.SignUp.makeStudent(SignUp.java:94) 
at professionalgrader.professionalgrader.SignUp.access$500(SignUp.java:16) 
at professionalgrader.professionalgrader.SignUp$1.onClick(SignUp.java:45) 
at android.view.View.performClick(View.java:5198) 
at android.view.View$PerformClick.run(View.java:21147) 
at android.os.Handler.handleCallback(Handler.java:739) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
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 'double professionalgrader.professionalgrader.Class.getGPA()' on a null object reference
at professionalgrader.professionalgrader.Student.getTotalGPA(Student.java:199)
at java.lang.reflect.Method.invoke(Native Method)
at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.get(BeanPropertyWriter.java:679)
at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:534)
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:597)
at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:142) 
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:118) 
at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:2593) 
at com.fasterxml.jackson.databind.ObjectMapper.convertValue(ObjectMapper.java:2542) 
at com.firebase.client.Firebase.setValueInternal(Firebase.java:336) 
at com.firebase.client.Firebase.setValue(Firebase.java:238) 
at professionalgrader.professionalgrader.SignUp.makeStudent(SignUp.java:94) 
at professionalgrader.professionalgrader.SignUp.access$500(SignUp.java:16) 
at professionalgrader.professionalgrader.SignUp$1.onClick(SignUp.java:45) 
at android.view.View.performClick(View.java:5198) 
at android.view.View$PerformClick.run(View.java:21147) 
at android.os.Handler.handleCallback(Handler.java:739) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
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) 
Possible source of error because it told me it couldn't obtain the Snapshot at the line in makeStudent(), but makeStudent() doesn't use Snapshot. Only userExists() does. Note: The variable 'exists' is defined as a static boolean in the SignUp class.
private boolean userExists() {
Firebase ref = new Firebase("MYAPPNAME.firebaseio.com");
ref.addValueEventListener(new ValueEventListener() {
#Override
public void onDataChange(DataSnapshot snapshot) {
for (DataSnapshot postSnapShot: snapshot.getChildren()) {
Student s = postSnapShot.getValue(Student.class);
if(s.getEmail().equals(mEmailView.getText().toString())) {
exists = true;
}
}
}
#Override
public void onCancelled(FirebaseError firebaseError) {
exists = true;
}
});
return exists;
}
SOLUTION TO MY ISSUE:
I realized that Snapshot was never used in makeStudent(), and that was where the error started. Thus, I looked in the only place it was used... userExists(), and it turned out that I was correct! The error was produced by trying to identify Student s as a nonexistent student! Thus, I actually needed a try like such:
private boolean userExists() {
Firebase ref = new Firebase("MYAPPNAME.firebaseio.com");
ref.addValueEventListener(new ValueEventListener() {
#Override
public void onDataChange(DataSnapshot snapshot) {
Student s;
for (DataSnapshot postSnapShot: snapshot.getChildren()) {
try {
s = postSnapShot.getValue(Student.class);
if(s.getEmail().equals(mEmailView.getText().toString())) {
System.out.println(snapshot.getValue());
exists = true;
}
} catch(Exception e) {
exists = false;
}
}
}
#Override
public void onCancelled(FirebaseError firebaseError) {
exists = true;
}
});
return exists;
}

Categories

Resources