Flutter Firebase Authentication app crashes after creating user - flutter

I've been using firebase services for quite some time.
So i started a new flutter project yesterday and i'm experiencing app crashes, some times when when a user registers an account With Firebase Auth. according to console log, its probably because of invoking onAuthStateChanged.
Can anyone help me resolve this.
NB: Sometimes an account is created successfully without the app crashing.
This is the code where i call onAuthStateChanged :
User _userFromFirebase(FirebaseUser user){
return user != null ? User(uid: user.uid, email: user.email, name: user.displayName, phoneNo: user.phoneNumber)
: null ;
}
Stream<User> get user {
return _auth.onAuthStateChanged.map(_userFromFirebase);
}
Below is the debug console output;
D/FirebaseAuth(14930): Notifying id token listeners about user ( VZcLcnr4dJOZgLjFYU3ls96yHK13 ).
D/FirebaseAuth(14930): Notifying auth state listeners about user ( VZcLcnr4dJOZgLjFYU3ls96yHK13 ).
D/AndroidRuntime(14930): Shutting down VM
E/AndroidRuntime(14930): FATAL EXCEPTION: main
E/AndroidRuntime(14930): Process: com.tonnyapps.app3, PID: 14930
E/AndroidRuntime(14930): java.lang.NullPointerException: Attempt to invoke virtual method 'void io.flutter.plugin.common.MethodChannel.invokeMethod(java.lang.String, java.lang.Object)' on a null object reference
E/AndroidRuntime(14930): at io.flutter.plugins.firebaseauth.FirebaseAuthPlugin$3.onAuthStateChanged(FirebaseAuthPlugin.java:710)
E/AndroidRuntime(14930): at com.google.firebase.auth.zzp.run(com.google.firebase:firebase-auth##19.2.0:3)
E/AndroidRuntime(14930): at android.os.Handler.handleCallback(Handler.java:873)
E/AndroidRuntime(14930): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(14930): at com.google.android.gms.internal.firebase_auth.zzj.dispatchMessage(com.google.firebase:firebase-auth##19.2.0:6)
E/AndroidRuntime(14930): at android.os.Looper.loop(Looper.java:214)
E/AndroidRuntime(14930): at android.app.ActivityThread.main(ActivityThread.java:7050)
E/AndroidRuntime(14930): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(14930): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
E/AndroidRuntime(14930): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
I/Process (14930): Sending signal. PID: 14930 SIG: 9
Lost connection to device.

After many efforts tweaking around with the code and updating dependencies to support higher versions of firebase_auth. I was able to upgrade and fix the version of firebase_auth to version 0.20.1, since it was the last non null-safe version.
And Wallah, it worked, this must have been a bug with whatever version i was using. But it was solved with later releases. The users can now create users successfully and proceed with the normal app flow.
So setting firebase_auth: 0.20.1 in the pubspec.yaml, worked for me.

Since, the project is old, I would recommend the best option is updating all the code, and preferably migrating the project to null safety. This should give you more control over the project future development, and also probably fix the bugs you are experiencing with the old code.

Related

Unable to start receiver com.google.android.finsky.instantapps.PhenotypeUpdateReceiver: java.lang.IllegalStateException

I have released my game to play console which is made using Unity. The Pre-launch report, reported the following crash issues during internal testing.
java.lang.RuntimeException: Unable to start receiver com.google.android.finsky.instantapps.PhenotypeUpdateReceiver: java.lang.IllegalStateException: Not allowed to start service Intent { act=com.google.android.gms.phenotype.UPDATE cmp=com.android.vending/com.google.android.finsky.instantapps.PhenotypeUpdateService }: app is in background uid UidRecord{46dceb4 u0a249 TRNB bg:+10m41s432ms idle change:uncached procs:4 proclist:29801,29978,30388,30591, seq(0,0,0)}
AND
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
I am not sure, where exactly the error is and why?
Full trace for the first issue:
FATAL EXCEPTION: main
Process: com.android.vending:instant_app_installer, PID: 19323
java.lang.RuntimeException: Unable to start receiver com.google.android.finsky.instantapps.PhenotypeUpdateReceiver: android.app.BackgroundServiceStartNotAllowedException: Not allowed to start service Intent { act=com.google.android.gms.phenotype.UPDATE cmp=com.android.vending/com.google.android.finsky.instantapps.PhenotypeUpdateService }: app is in background uid UidRecord{64ad173 u0a135 TRNB bg:+13m22s373ms idle change:uncached procs:0 seq(0,0,0)}
at android.app.ActivityThread.handleReceiver(ActivityThread.java:4317)
at android.app.ActivityThread.access$1600(ActivityThread.java:247)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2064)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7839)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
Caused by: android.app.BackgroundServiceStartNotAllowedException: Not allowed to start service Intent { act=com.google.android.gms.phenotype.UPDATE cmp=com.android.vending/com.google.android.finsky.instantapps.PhenotypeUpdateService }: app is in background uid UidRecord{64ad173 u0a135 TRNB bg:+13m22s373ms idle change:uncached procs:0 seq(0,0,0)}
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1861)
at android.app.ContextImpl.startService(ContextImpl.java:1817)
at android.content.ContextWrapper.startService(ContextWrapper.java:774)
at alj.a(PG:2)
at alm.a(PG:3)
at wnv.a(PG:2)
at com.google.android.finsky.instantapps.PhenotypeUpdateReceiver.onReceive(PG:6)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:4308)
... 9 more
Full trace for the second issue:
FATAL EXCEPTION: pool-3-thread-1
Process: com.HefazSofts.AayaanTheRunner, PID: 19257
java.lang.IllegalArgumentException: com.HefazSofts.AayaanTheRunner: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
at androidx.work.impl.utils.ForceStopRunnable.getPendingIntent(ForceStopRunnable.java:174)
at androidx.work.impl.utils.ForceStopRunnable.isForceStopped(ForceStopRunnable.java:108)
at androidx.work.impl.utils.ForceStopRunnable.run(ForceStopRunnable.java:86)
at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:75)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:920)

Cant access firebase/firestore when cloning flutter project to another computer

I have uploaded my project on github and cloned to another computer. It compiles fine but it hasnt got access to Firbase/firestore and therefore i cant use this cloned project properly with authentication and so on.
Do I have to change something when I clone a flutter app with firebase to another computer to make it work and gain access to the database and the authentication?
Errormessage:
D/EGL_emulation(10634): app_time_stats: avg=6275.84ms min=9.86ms max=106419.61ms count=17
D/EGL_emulation(10634): app_time_stats: avg=11.48ms min=5.31ms max=40.71ms count=60
D/EGL_emulation(10634): app_time_stats: avg=9.29ms min=4.92ms max=16.29ms count=56
D/EGL_emulation(10634): app_time_stats: avg=8.66ms min=5.06ms max=15.26ms count=61
D/EGL_emulation(10634): app_time_stats: avg=9.94ms min=4.58ms max=24.23ms count=61
D/EGL_emulation(10634): app_time_stats: avg=10.22ms min=5.13ms max=20.02ms count=60
D/EGL_emulation(10634): app_time_stats: avg=8.59ms min=4.91ms max=15.28ms count=60
D/EGL_emulation(10634): app_time_stats: avg=8.31ms min=5.03ms max=16.29ms count=61
D/EGL_emulation(10634): app_time_stats: avg=8.91ms min=4.52ms max=14.01ms count=61
D/EGL_emulation(10634): app_time_stats: avg=9.90ms min=4.90ms max=17.99ms count=60
I/flutter (10634): 2 false
D/EGL_emulation(10634): app_time_stats: avg=9.15ms min=5.06ms max=22.87ms count=60
D/EGL_emulation(10634): app_time_stats: avg=83.28ms min=12.88ms max=1016.12ms count=15
W/Firestore(10634): (24.4.0) [WatchStream]: (24ebbad) Stream closed with status: Status{code=UNAVAILABLE, description=Channel shutdownNow invoked, cause=null}.
W/DynamiteModule(10634): Local module descriptor class for com.google.android.gms.providerinstaller.dynamite not found.
I/DynamiteModule(10634): Considering local module com.google.android.gms.providerinstaller.dynamite:0 and remote module com.google.android.gms.providerinstaller.dynamite:0
W/ProviderInstaller(10634): Failed to load providerinstaller module: No acceptable module com.google.android.gms.providerinstaller.dynamite found. Local version is 0 and remote version is 0.
this could have many reasons.
Check your GitIgnore maybe some Firebase config files were not uploaded to Github and are therefore missing in the cloned project.
Check your Firebase security rules. Check how you are allowed to access your DB.
If this didn't work, provide the thrown error, please.
Solution:
It happend to be that the android emulator on my other computer was a bad version where firebase didn’t work correctly.
I only had to downgrade from android emulator 31.3.10 then everything worked fine.
This video shows how:
https://youtu.be/qo3SbdbXFos

java.lang.IllegalStateException: Reply already submitted | DartMessenger | FlutterLocation

Receiving java.lang.IllegalStateException: Reply already submitted in Flutter Location.java. This is very frequent crash appears in Crashliytics logs.
I have used plugin location: ^3.2.4
Didn't find any solution, below is crash logs:
Caused by java.lang.IllegalStateException: Reply already submitted
at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:35)
at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error(MethodChannel.java:14)
at com.lyokone.location.FlutterLocation.onActivityResult(FlutterLocation.java:43)
at io.flutter.embedding.engine.FlutterEnginePluginRegistry$FlutterEngineActivityPluginBinding.onActivityResult(FlutterEnginePluginRegistry.java:25)
at io.flutter.embedding.engine.FlutterEnginePluginRegistry.onActivityResult(FlutterEnginePluginRegistry.java:15)
at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onActivityResult(FlutterActivityAndFragmentDelegate.java:51)
at io.flutter.embedding.android.FlutterActivity.onActivityResult(FlutterActivity.java:2)
at android.app.Activity.dispatchActivityResult(Activity.java:8300)
at android.app.ActivityThread.deliverResults(ActivityThread.java:5353)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:5401)
at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2267)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:8167)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
In above log you can see exception is in FlutterLocation.java which is a part of location plugin

Fatal Exception: java.lang.RuntimeException: Unable to destroy activity {com.example.app.MainActivity}: java.lang.IllegalArgumentException:

My flutter application keeps on crashing and logging this error on firebase crash analytics
Fatal Exception: java.lang.RuntimeException: Unable to destroy activity {com.aims.covidsurvey/com.example.app.MainActivity}: java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter activity
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4463)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4482)
at android.app.ActivityThread.-wrap6(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1640)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6617)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
Have tried to debug the app, am not getting much information what is causing the error, anyone know what could be causing this and how to fix it? Have tried to research am not getting much information
the Kotlin code generated by the app
package com.example.app
import io.flutter.embedding.android.FlutterActivity
class MainActivity: FlutterActivity() {
}
And another crash error
Caused by java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter activity
at com.lyokone.location.FlutterLocationService.setActivity(FlutterLocationService.kt)
at com.lyokone.location.LocationPlugin.deinitialize(LocationPlugin.java:121)
at com.lyokone.location.LocationPlugin.detachActivity(LocationPlugin.java:56)
at com.lyokone.location.LocationPlugin.onDetachedFromActivity(LocationPlugin.java:69)
at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.detachFromActivity(FlutterEngineConnectionRegistry.java:389)
at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onDetach(FlutterActivityAndFragmentDelegate.java:556)
at io.flutter.embedding.android.FlutterActivity.release(FlutterActivity.java:587)
at io.flutter.embedding.android.FlutterActivity.onDestroy(FlutterActivity.java:608)
at android.app.Activity.performDestroy(Activity.java:7136)
at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1158)
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4450)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4482)
at android.app.ActivityThread.-wrap6(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1640)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6617)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
My solution was to change the component location to geolocator
https://pub.dev/packages/geolocator

Weex Library Crash on Android

I am getting this random crash in weex on android platform.
Weex version details-
v1.3.8
- weexpack : v1.2.3
- weex-builder : v0.4.0
- weex-previewer : v1.5.1
Facing a crash in sdk : java.lang.NullPointerException: Attempt to invoke virtual method 'com.taobao.weex.ui.flat.WidgetContainer com.taobao.weex.ui.flat.FlatGUIContext.getFlatComponentAncestor(com.taobao.weex.ui.component.WXComponent)' on a null object reference
at com.taobao.weex.ui.component.WXComponent.setComponentLayoutParams(WXComponent.java:559)
at com.taobao.weex.ui.component.WXComponent.setLayout(WXComponent.java:551)
at com.taobao.weex.ui.RenderActionContextImpl.setLayout(RenderActionContextImpl.java:82)
at com.taobao.weex.ui.WXRenderManager.setLayout(WXRenderManager.java:150)
at com.taobao.weex.dom.DOMActionContextImpl$ApplyUpdateConsumer$1.execute(DOMActionContextImpl.java:276)
at com.taobao.weex.ui.WXRenderManager$1.run(WXRenderManager.java:104)
at com.taobao.weex.common.WXThread$SafeRunnable.run(WXThread.java:48)
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:6592)
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:769)
Already fixed, not released yet. You can build from source if emergency.