Flutter:- already_active, Image picker is already active, null, null - firebase

Everytime I'm pressing pick image in release mode it's showing me this error
E/flutter (24004): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: PlatformException(already_active, Image picker is already active, null, null)
E/flutter (24004): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:581)
E/flutter (24004): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:158)
E/flutter (24004): <asynchronous suspension>
E/flutter (24004): #2 MethodChannelImagePicker.pickImage (package:image_picker_platform_interface/src/method_channel/method_channel_image_picker.dart:29)
E/flutter (24004): <asynchronous suspension>
E/flutter (24004): #3 _UploadDataCardState.getImage (package:visual_retail/screens/FillData/UploadDataCard.dart:164)
E/flutter (24004): <asynchronous suspension>
E/flutter (24004):
In debug mode it's working properly

Downgrade Gradle version to : classpath 'com.android.tools.build:gradle:3.5.4'

after downgrading Gradle version change kotlin version
this is my version ext.kotlin_version = '1.6.10' for 'com.android.tools.build:gradle:4.1.0'
find yours
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()
}

Related

Firebase Functions https call does not work on emulator

When executing the https call on the firebase emulator i only get a FirebaseFunctionException. Every other function, except the https call, works fine. When connecting to firebase without the emulator everything works as well. I can´t find a solution for this on the internet, can someone please help?
Method call:
try {
HttpsCallable callable =
FirebaseFunctions.instance.httpsCallable('getBookData');
final results = await callable.call(parameters);
Init:
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
...
final localHostString = Platform.isAndroid ? '10.0.2.2' : 'localhost';
// dotenv.get('HOST_IP');
FirebaseFunctions.instance
.useFunctionsEmulator('http://$localHostString', 5001);
FirebaseFirestore.instance.settings = Settings(
host: '$localHostString:8080',
sslEnabled: false,
persistenceEnabled: false,
);
await auth.FirebaseAuth.instance.useEmulator(
Platform.isAndroid ? 'http://localhost:9099' : 'http://0.0.0.0:9099');
}
Exception:
code:"unavailable"
details:null
message:"UNAVAILABLE"
plugin:"firebase_functions"
stackTrace:#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607:7)
#1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156:18)
<asynchronous suspension>
#2 MethodChannelHttpsCallable.call (package:cloud_functions_platform_interface/src/method_channel/method_channel_https_callable.dart:23:24)
<asynchronous suspension>
#3 HttpsCallable.call (package:cloud_functions/src/https_callable.dart:35:37)
<asynchronous suspension>
#4 BookRequest._requestBooksFromCloudFunction (package:bookR/shared/bookRequest.dart:47:23)
<asynchronous suspension>
#5 BookRequest.getMoreBooksByTitle (package:bookR/shared/bookRequest.dart:23:24)
<asynchronous suspension>
#6 BookRequest.getBookInformationByTitle (package:bookR/shared/bookRequest.dart:37:13)
<asynchronous suspension>
#7 SearchBar.build.<anonymous closure> (package:bookR/widgets/searchBar.dart:34:28)
<asynchronous suspension>
hashCode:439854717
runtimeType:Type (FirebaseFunctionsException)
I finally figured it out! :D
In case somebody finds this in the future:
FirebaseFunctions.instance
.useFunctionsEmulator('http://$localHostString', 5001);
This causes the error. The correct version is:
FirebaseFunctions.instance
.useFunctionsEmulator('$localHostString', 5001);
Now erverthing works as expected

Failed assertion: line 67 pos 16: 'map['projectId'] != null': 'projectId' cannot be null

Suddenly my app start showing following error:
E/flutter (16810): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: 'package:firebase_core_platform_interface/src/firebase_options.dart': Failed assertion: line 67 pos 16: 'map['projectId'] != null': 'projectId' cannot be null.
E/flutter (16810): #0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:46:39)
E/flutter (16810): #1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:36:5)
E/flutter (16810): #2 new FirebaseOptions.fromMap (package:firebase_core_platform_interface/src/firebase_options.dart:67:16)
E/flutter (16810): #3 MethodChannelFirebase._initializeFirebaseAppFromMap (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:44:23)
E/flutter (16810): #4 ListMixin.forEach (dart:collection/list.dart:86:13)
E/flutter (16810): #5 MethodChannelFirebase._initializeCore (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:34:10)
E/flutter (16810): <asynchronous suspension>
E/flutter (16810): #6 MethodChannelFirebase.initializeApp (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:75:7)
E/flutter (16810): <asynchronous suspension>
E/flutter (16810): #7 Firebase.initializeApp (package:firebase_core/src/firebase.dart:44:9)
E/flutter (16810): <asynchronous suspension>
E/flutter (16810): #8 main (package:athomedoc/main.dart:10:3)
E/flutter (16810): <asynchronous suspension>
E/flutter (16810):
according to error you are getting null value of projectId, you can print/debug before using it, to make sure you are getting data from source.

MissingPluginException exception when I try to connect my app to firebase authentication

When I try to initialize firebase with my flutter project I get this error:
[ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: MissingPluginException(No implementation found for method Firebase#initializeCore on channel plugins.flutter.io/firebase_core)
At first I thought that it had something to do with the firebase core page but I've tried to use older page and I still get the same error
The complete error:
E/flutter ( 8415): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: MissingPluginException(No implementation found for method Firebase#initializeCore on channel plugins.flutter.io/firebase_core)
E/flutter ( 8415): #0 MethodChannel._invokeMethod
package:flutter/…/services/platform_channel.dart:157
E/flutter ( 8415): <asynchronous suspension>
E/flutter ( 8415): #1 MethodChannel.invokeMethod
package:flutter/…/services/platform_channel.dart:332
E/flutter ( 8415): #2 MethodChannel.invokeListMethod
package:flutter/…/services/platform_channel.dart:345
E/flutter ( 8415): #3 MethodChannelFirebase._initializeCore (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:30:36)
E/flutter ( 8415): #4 MethodChannelFirebase.initializeApp (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:75:13)
E/flutter ( 8415): #5 Firebase.initializeApp (package:firebase_core/src/firebase.dart:43:25)
E/flutter ( 8415): #6 main
package:crypto_wallet/main.dart:7
E/flutter ( 8415): #7 _runMainZoned.<anonymous closure>.<anonymous closure> (dart:ui/hooks.dart:231:25)
E/flutter ( 8415): #8 _rootRun (dart:async/zone.dart:1190:13)
E/flutter ( 8415): #9 _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter ( 8415): #10 _runZoned (dart:async/zone.dart:1630:10)
E/flutter ( 8415): #11 runZonedGuarded (dart:async/zone.dart:1618:12)
E/flutter ( 8415): #12 _runMainZoned.<anonymous closure> (dart:ui/hooks.dart:223:5)
E/flutter ( 8415): #13 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:301:19)
E/flutter ( 8415): #14 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
E/flutter ( 8415):
The dependencies :
dependencies:
flutter:
sdk: flutter
firebase_core: "^0.5.0+1"
firebase_auth: "^0.18.1+2"
cloud_firestore: "^0.14.1+3"
This is my main function:
void main () async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}
the build.gradle file (dependencies)
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.google.gms:google-services:4.3.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
I assume that you have the same issue as here. So you need to change the relevant part in your build.gradle file with the following:
'com.android.tools.build:gradle:3.5.0'
You can read more from here.

Flutter Firestore Error performing updateData, No Document found to update

Im using Firestore for mu Flutter project.
I cannot update a field in a document. It results in error (error performing update, No document found)
Code:
await Firestore.instance.collection('QuizProfile').document("20200528-KYUMI").updateData(
{
'Slot': 'asdfg',
},
);
}
Error message ::
E/flutter (18326): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception:
PlatformException(Error performing updateData, NOT_FOUND:
No document to update: projects/fir-2d2f0/databases/(default)/documents/QuizProfile/20200528-KYUMI, null)
E/flutter (18326): #0 StandardMethodCodec.decodeEnvelope
package:flutter/…/services/message_codecs.dart:569
E/flutter (18326): #1 MethodChannel.invokeMethod
package:flutter/…/services/platform_channel.dart:321
E/flutter (18326): <asynchronous suspension>
E/flutter (18326): #2 MethodChannelDocumentReference.updateData
package:cloud_firestore_platform_interface/…/method_channel/method_channel_document_reference.dart:41
E/flutter (18326): #3 DocumentReference.updateData
package:cloud_firestore/src/document_reference.dart:60
E/flutter (18326): #4 Model.pushscore
package:firestoredemo/models/QA_Model.dart:214
E/flutter (18326): <asynchronous suspension>
E/flutter (18326): #5 _CustomTextState.initState
package:firestoredemo/CustomText.dart:21
Firestore database screenshot

I am unable to Sign in using phone verification on Firebase using Flutter and fuurebase_auth plugin

I keep getting this error below:
The method 'signInWithCredential' was called on null.
[ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: NoSuchMethodError: The method 'signInWithCredential' was called on null.
E/flutter (29053): Receiver: null
E/flutter (29053): Tried calling: signInWithCredential(Instance of 'AuthCredential')
E/flutter (29053): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:50:5)
E/flutter (29053): #1 _LoginScreenState._signInWithPhoneNumber (package:jollycab_flutter/screens/login_screen.dart:74:43)
E/flutter (29053): <asynchronous suspension>
E/flutter (29053): #2 _LoginScreenState.build.<anonymous closure> (package:jollycab_flutter/screens/login_screen.dart:384:23)
E/flutter (29053): <asynchronous suspension>
E/flutter (29053): #3 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:511:14)
E/flutter (29053): #4 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:566:30)
E/flutter (29053): #5 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:166:24)
E/flutter (29053): #6 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:240:9)
E/flutter (29053): #7 TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:177:9)
I am using the code example from the flutter team here:
https://github.com/flutter/plugins/blob/master/packages/firebase_auth/example/lib/signin_page.dart
The Code starts from line 508. For some reason, signInWithCredential does not seem to be getting what it wants or is not working
if you used the example, then somewhere in the code you have _auth.signInWithCredential and _auth is null, you missing the initialization of it. or you are initializing it with invalid value (null?)

Resources