App crashes in android

I made a Socialmedia app where you post stories, the user has to log in or register when he first opens the app, the problem is: when the user logs in the app crashes, I installed firebase Crashlyltics and the error shown is “java.lang.error”, I tried searching the internet but no useful results was found, how can I fix it?

Dig more into the stacktrace provided from Crashlytics to find out what module might have crashed.

You may also get some intel from the adb logcat stream.

Beyond that it might be necessary to instrument your code more.

What is often happening in these cases is one of the following:

  • the code you think is executing is not actually executing at all
  • the code is executing far EARLIER or LATER than you think
  • the code is executing far LESS OFTEN than you think
  • the code is executing far MORE OFTEN than you think
  • the code is executing on another GameObject than you think it is

To help gain more insight into your problem, I recommend liberally sprinkling Debug.Log() statements through your code to display information in realtime.

Doing this should help you answer these types of questions:

  • is this code even running? which parts are running? how often does it run? what order does it run in?
  • what are the values of the variables involved? Are they initialized? Are the values reasonable?
  • are you meeting ALL the requirements to receive callbacks such as triggers / colliders (review the documentation)

Knowing this information will help you reason about the behavior you are seeing.

You can also put in Debug.Break() to pause the Editor when certain interesting pieces of code run, and then study the scene

You could also just display various important quantities in UI Text elements to watch them change as you play the game.

If you are running a mobile device you can also view the console output. Google for how on your particular mobile target.

Here’s an example of putting in a laser-focused Debug.Log() and how that can save you a TON of time wallowing around speculating what might be going wrong:

This is the full error shown:
error(
Caused by java.lang.Error: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Version ‘2020.3.13f1 (71691879b7f5)’, Build type ‘Release’, Scripting Backend ‘mono’, CPU ‘armeabi-v7a’
Build fingerprint: ‘samsung/d2sxx/d2s:11/RP1A.200720.012/N975FXXS7FUF5:user/release-keys’
Revision: ‘24’
ABI: ‘arm’
Timestamp: 2021-08-23 22:21:49+0300
pid: 3023, tid: 11488, name: UnityMain >>> com.Kotaro.untoldStories <<<
uid: 15478
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x4
Cause: null pointer dereference
r0 00000000 r1 00000000 r2 00000001 r3 00000000
r4 a1354ed0 r5 00000000 r6 00000000 r7 b5639348
r8 a2a31390 r9 00000003 r10 00000003 r11 b3cbb100
ip a28678e0 sp b3cbb0e0 lr a279b9f1 pc a27d27cc

backtrace:
#00 pc 0018e7cc /data/app/~~XWlttvqZ4WfkmhGQ4fq8kA==/com.Kotaro.untoldStories-_rp_y7naAa2Yui_mypTO8w==/lib/arm/libFirebaseCppApp-8_0_0.so (firebase::firestore::csharp::TransactionManager::TransactionManager(firebase::firestore::Firestore*)+16) (BuildId: 6a67c5675f8b718a3e53772c17d2a166)
#01 pc 00189307 /data/app/~~XWlttvqZ4WfkmhGQ4fq8kA==/com.Kotaro.untoldStories-_rp_y7naAa2Yui_mypTO8w==/lib/arm/libFirebaseCppApp-8_0_0.so (Firebase_Firestore_CSharp_new_TransactionManagerProxy+14) (BuildId: 6a67c5675f8b718a3e53772c17d2a166)
#02 pc 00001efe anonymous:a1b83000

managed backtrace:
#00 (wrapper managed-to-native) Firebase.Firestore.FirestoreCppPINVOKE:new_TransactionManagerProxy (System.Runtime.InteropServices.HandleRef)
#01 Firebase.Firestore.TransactionManagerProxy:.ctor (Firebase.Firestore.FirestoreProxy) <0x27>
#02 Firebase.Firestore.TransactionManager:.ctor (Firebase.Firestore.FirebaseFirestore,Firebase.Firestore.FirestoreProxy) <0x3f>
#03 Firebase.Firestore.FirebaseFirestore:.ctor (Firebase.Firestore.FirestoreProxy,Firebase.FirebaseApp) <0x103>
#04 Firebase.Firestore.FirebaseFirestore:GetInstance (Firebase.FirebaseApp) <0xcb>
#05 Firebase.Firestore.FirebaseFirestore:get_DefaultInstance () <0xb>
#06 UserInfoLoader:Awake (<truncated: 108 chars>
at libFirebaseCppApp-8_0_0.firebase::firestore::csharp::TransactionManager::TransactionManager(firebase::firestore::Firestore*)(TransactionManager:16)
at libFirebaseCppApp-8_0_0.Firebase_Firestore_CSharp_new_TransactionManagerProxy(Firebase_Firestore_CSharp_new_TransactionManagerProxy:14)
at Firebase.Firestore.FirestoreCppPINVOKE.new_TransactionManagerProxy (System.Runtime.InteropServices.HandleRef)()
at Firebase.Firestore.TransactionManagerProxy…ctor (Firebase.Firestore.FirestoreProxy)(0x27:39)
at Firebase.Firestore.TransactionManager…ctor (Firebase.Firestore.FirebaseFirestore,Firebase.Firestore.FirestoreProxy)(0x3f:63)
at Firebase.Firestore.FirebaseFirestore…ctor (Firebase.Firestore.FirestoreProxy,Firebase.FirebaseApp)(0x103:259)
at Firebase.Firestore.FirebaseFirestore.GetInstance (Firebase.FirebaseApp)(0xcb:203)
at Firebase.Firestore.FirebaseFirestore.get_DefaultInstance ()(0xb:11)
at UserInfoLoader.Awake ()(0xf:15)
at System.Object.runtime_invoke_void__this__ (object,intptr,intptr,intptr)()
)

I tried many things and the only thing I can think of is that firebase is causing the error, or maybe multithreading

It looks like just a bog-standard run-of-the-mill null reference. I would first go over everything necessary for setting up that firestore thing, perhaps making sure if it needs any callbacks or other bits of initialization info to function.