I am trying to capture the error thrown by firstore plugin in flutter when listening to document snapshots. The error is thrown in the debug logs but I cannot access it on catch error or handle error. Is this an enhancement needed for the plugin or is there a way?
Error in debug
I/System.out(16041): com.google.firebase.firestore.FirebaseFirestoreException: PERMISSION_DENIED: Missing or insufficient permissions.
Here is my code, I tried a number of ways but it didn't work
_getUserCollection.document(uid).snapshots();
_getUserCollection.document(uid).snapshots().handleError((onError) {
print(onError.toString());
});
try {
_getUserCollection.document(uid).snapshots();
} catch (e) {
print(e);
}
try {
_getUserCollection.document(uid).snapshots();
} on PlatformException catch (e) {
print(e.toString());
}
_getUserCollection.document(uid).snapshots().listen((event) {
print('here on listen');
}, onError: (e) {
print('on error $e');
});
"Missing or insufficient permissions" means that your query violated one of your security rules. You will need to examine those rules, and make sure they allow the query you intend to perform.
There is plenty of documentation for security rules, and it's necessary to understand how they work in order to work with Firestore effectively from web and mobile clients.
It's not true that you can't catch an error from a Firestore query. You can't use try/catch - you will have to pass an error handler to listen().
I was having the same issue. PERMISSION_DENIED was coming out in the logs but I wanted to catch the error myself so that I could display it to the user. I found this issue on GitHub:
Firebase - native error messages not provided issue
It states that a lot of work has been done to improve the error handling in Firebase. So I spent yesterday upgrading my app to the latest version of firebase_auth (0.18.0 at the time of writing) and I can now catch and handle the PERMISSION_DENIED error like this:
return StreamBuilder<List<DistanceDocSnapshot>>(
stream: _eventStream,
builder: (BuildContext context,
AsyncSnapshot<List<DistanceDocSnapshot>> snapshot) {
if (snapshot.hasError) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'Error retrieving events: ${snapshot.error.toString()}',
style: TextStyle(fontSize: 20.0),
textAlign: TextAlign.center,
),
);
}
if (snapshot.hasData) {
// Handle data as desired
}
}
);
This can be seen working in the following screenshot Screenshot of error on my app (I had to provide a link to the screenshot because I don't have enough rep to embed images yet)
My code is laid out differently to yours but I think yours will start working as desired if you just upgrade your firebase_auth version.
When trying to get a document from Firestore, if the device is connected through Wifi the connection fails with the following error message:
W/Firestore( 4903): (21.4.3) [OnlineStateTracker]: Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds
W/Firestore( 4903): This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.
To Reproduce
Usually, the error happens when running in a Physical device.
I created a small app to be able to reproduce the errors with minimal interference from the rest of my code. See the code below.
When you hit run on the debugger (I'm using VSCode) and then I click on the (+) button to make the request to Firestore, it stays trying for a few seconds (you'll see the progress indicator no the test app) and then the call snapshot = await docRef.get() fails with the following error message:
PlatformException(Error performing get, Failed to get document because the client is offline., null)
Then, if you turn the wifi off, the request works perfectly. And the content of the document retrieved from Firestore is present in the screen:
Now if you turn the wifi again, the request works. Sometimes the data is retrieved from the server and other from the cache.
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Firestore Network Bug',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
#override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
bool _loading = false;
Map<String, dynamic> _firebaseDocument;
String _firebaseError;
String _source;
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Firestore Network Bug"),
),
body: Padding(
padding: const EdgeInsets.all(24),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Text('Tap the (+) button to try to read from Firestore...',
style: TextStyle(fontSize: 20)),
_showProgress(),
_showResults(),
_showErrors(),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _readFromFirebase,
tooltip: 'Increment',
child: Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
Widget _showProgress() {
return Padding(
padding: const EdgeInsets.only(top: 12.0),
child: Container(
height: 6.0,
child: (_loading) ? LinearProgressIndicator() : Container(),
),
);
}
Widget _showResults() {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: 12.0),
Text("Result:"),
Container(
height: 150,
padding: const EdgeInsets.all(16),
color: Colors.blue[100],
child: (_firebaseDocument != null)
? Text("From $_source: \n\n" + _firebaseDocument?.toString(),
style: TextStyle(fontSize: 16))
: Container(),
),
],
);
}
Widget _showErrors() {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: 12.0),
Text("Errors:"),
Container(
height: 150,
padding: const EdgeInsets.all(16),
color: Colors.red[100],
child: (_firebaseError != null)
? Text(_firebaseError?.toString(), style: TextStyle(fontSize: 16))
: Container(),
),
],
);
}
void _readFromFirebase() async {
setState(() {
_loading = true;
_firebaseDocument = null;
_firebaseError = null;
});
DocumentReference docRef =
Firestore.instance.document("myCollection/myDocument");
DocumentSnapshot snapshot = await docRef.get().catchError(
(onError) {
setState(() {
_loading = false;
_firebaseDocument = null;
_firebaseError = onError.toString();
});
},
);
if (_firebaseError != null) return;
_source = (snapshot.metadata.isFromCache) ? "cache" : "server";
if (snapshot.exists) {
setState(() {
_loading = false;
_firebaseDocument = snapshot.data;
});
print("Document found!");
print("- ${_firebaseDocument.toString()}");
} else {
print("Document not found!");
}
}
}
Expected behavior
Since the device has perfect connectivity over wifi, it was excepted that the request worked fine and the document was retrieved from the server.
Additional context
On the emulator, everything works perfectly.
I tested in the following emulator configurations: Pixel 4 API 29, Pixel 5 API 25, Pixel 3 API 29.
The physical devices I used to test (both failed identically) where: Pixel 4XL (Android 10 QQ3Q.200605.001) and Pixel 3XL (Android 10 QQ2A.200305.002).
Flutter doctor
[✓] Flutter (Channel stable, v1.17.3, on Mac OS X 10.15.4 19E287, locale en-US)
• Flutter version 1.17.3 at /Users/mlemos/Documents/flutter
• Framework revision b041144f83 (8 days ago), 2020-06-04 09:26:11 -0700
• Engine revision ee76268252
• Dart version 2.8.4
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/mlemos/Library/Android/sdk
• Platform android-30, build-tools 29.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.5, Build version 11E608c
• CocoaPods version 1.9.1
[!] Android Studio (version 4.0)
• Android Studio at /Applications/Android Studio.app/Contents
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
[✓] VS Code (version 1.46.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.11.0
[✓] Connected device (2 available)
• Pixel 4 XL • 99201FFBA000KF • android-arm64 • Android 10 (API 29)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 7.1.1 (API 25) (emulator)
! Doctor found issues in 1 category.
pubspec.yaml
name: firestore_network_bug
description: A new Flutter project.
publish_to: 'none'
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.3
firebase_analytics: ^5.0.14
cloud_firestore: ^0.13.6
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
/build.gradle
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// Application specific configuration (dependencies)
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.1.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
/app/build.gradle
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
// Application specific configuration (plugins)
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
android {
compileSdkVersion 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
applicationId "com.example.firestore_network_bug"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
// Application specific configuration (multidex)
multiDexEnabled true
}
buildTypes {
release {
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// Application specific configuration (dependencies)
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.firebase:firebase-analytics:17.2.2'
implementation 'com.google.firebase:firebase-crashlytics:17.0.0'
implementation 'com.google.firebase:firebase-firestore:21.4.3'
}
Here is the debug console output:
Over Wifi - When the error happens
Please note that, over Wifi, Crashlytics also fails.
Launching lib/main.dart on Pixel 4 XL in debug mode...
✓ Built build/app/outputs/apk/debug/app-debug.apk.
Connecting to VM Service at ws://127.0.0.1:54122/cahgKkWqnBU=/ws
E/FirebaseCrashlytics(22411): Settings request failed.
E/FirebaseCrashlytics(22411): java.io.InterruptedIOException: timeout
E/FirebaseCrashlytics(22411): at okhttp3.RealCall.timeoutExit(RealCall.java:107)
E/FirebaseCrashlytics(22411): at okhttp3.RealCall.execute(RealCall.java:96)
E/FirebaseCrashlytics(22411): at com.google.firebase.crashlytics.internal.network.HttpRequest.execute(com.google.firebase:firebase-crashlytics##17.0.0:129)
E/FirebaseCrashlytics(22411): at com.google.firebase.crashlytics.internal.settings.network.DefaultSettingsSpiCall.invoke(com.google.firebase:firebase-crashlytics##17.0.0:86)
E/FirebaseCrashlytics(22411): at com.google.firebase.crashlytics.internal.settings.SettingsController$1.then(com.google.firebase:firebase-crashlytics##17.0.0:200)
E/FirebaseCrashlytics(22411): at com.google.firebase.crashlytics.internal.settings.SettingsController$1.then(com.google.firebase:firebase-crashlytics##17.0.0:193)
E/FirebaseCrashlytics(22411): at com.google.android.gms.tasks.zzp.run(Unknown Source:2)
E/FirebaseCrashlytics(22411): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/FirebaseCrashlytics(22411): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/FirebaseCrashlytics(22411): at com.google.firebase.crashlytics.internal.common.ExecutorUtils$1$1.onRun(com.google.firebase:firebase-crashlytics##17.0.0:60)
E/FirebaseCrashlytics(22411): at com.google.firebase.crashlytics.internal.common.BackgroundPriorityRunnable.run(com.google.firebase:firebase-crashlytics##17.0.0:27)
E/FirebaseCrashlytics(22411): at java.lang.Thread.run(Thread.java:919)
E/FirebaseCrashlytics(22411): Caused by: java.io.IOException: Canceled
E/FirebaseCrashlytics(22411): at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)
E/FirebaseCrashlytics(22411): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
E/FirebaseCrashlytics(22411): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
E/FirebaseCrashlytics(22411): at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:254)
E/FirebaseCrashlytics(22411): at okhttp3.RealCall.execute(RealCall.java:92)
E/FirebaseCrashlytics(22411): ... 10 more
W/DynamiteModule(22411): Local module descriptor class for providerinstaller not found.
I/DynamiteModule(22411): Considering local module providerinstaller:0 and remote module providerinstaller:0
W/ProviderInstaller(22411): Failed to load providerinstaller module: No acceptable module found. Local version is 0 and remote version is 0.
I/ore_network_bu(22411): The ClassLoaderContext is a special shared library.
I/chatty (22411): uid=10227(com.example.firestore_network_bug) AsyncTask #1 identical 1 line
I/ore_network_bu(22411): The ClassLoaderContext is a special shared library.
W/ore_network_bu(22411): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
W/ore_network_bu(22411): Accessing hidden method Lsun/misc/Unsafe;->arrayBaseOffset(Ljava/lang/Class;)I (greylist,core-platform-api, linking, allowed)
W/ore_network_bu(22411): Accessing hidden method Lsun/misc/Unsafe;->copyMemory(JJJ)V (greylist, linking, allowed)
W/ore_network_bu(22411): Accessing hidden method Lsun/misc/Unsafe;->objectFieldOffset(Ljava/lang/reflect/Field;)J (greylist,core-platform-api, linking, allowed)
W/ore_network_bu(22411): Accessing hidden method Lsun/misc/Unsafe;->getByte(J)B (greylist,core-platform-api, linking, allowed)
W/ore_network_bu(22411): Accessing hidden method Lsun/misc/Unsafe;->getByte(Ljava/lang/Object;J)B (greylist,core-platform-api, linking, allowed)
W/ore_network_bu(22411): Accessing hidden method Lsun/misc/Unsafe;->getLong(J)J (greylist,core-platform-api, linking, allowed)
W/ore_network_bu(22411): Accessing hidden method Lsun/misc/Unsafe;->putByte(JB)V (greylist,core-platform-api, linking, allowed)
W/ore_network_bu(22411): Accessing hidden method Lsun/misc/Unsafe;->putByte(Ljava/lang/Object;JB)V (greylist,core-platform-api, linking, allowed)
W/ore_network_bu(22411): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, reflection, allowed)
W/ore_network_bu(22411): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, reflection, allowed)
W/ore_network_bu(22411): Accessing hidden field Ljava/nio/Buffer;->address:J (greylist, reflection, allowed)
V/NativeCrypto(22411): Registering com/google/android/gms/org/conscrypt/NativeCrypto's 286 native methods...
W/ore_network_bu(22411): Accessing hidden method Ljava/security/spec/ECParameterSpec;->getCurveName()Ljava/lang/String; (greylist, reflection, allowed)
I/ProviderInstaller(22411): Installed default security provider GmsCore_OpenSSL
W/Firestore(22411): (21.4.3) [OnlineStateTracker]: Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds
W/Firestore(22411):
W/Firestore(22411): This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.
W/DynamiteModule(22411): Local module descriptor class for providerinstaller not found.
I/DynamiteModule(22411): Considering local module providerinstaller:0 and remote module providerinstaller:0
W/ProviderInstaller(22411): Failed to load providerinstaller module: No acceptable module found. Local version is 0 and remote version is 0.
W/DynamiteModule(22411): Local module descriptor class for providerinstaller not found.
I/DynamiteModule(22411): Considering local module providerinstaller:0 and remote module providerinstaller:0
W/ProviderInstaller(22411): Failed to load providerinstaller module: No acceptable module found. Local version is 0 and remote version is 0.
W/DynamiteModule(22411): Local module descriptor class for providerinstaller not found.
I/DynamiteModule(22411): Considering local module providerinstaller:0 and remote module providerinstaller:0
W/ProviderInstaller(22411): Failed to load providerinstaller module: No acceptable module found. Local version is 0 and remote version is 0.
W/DynamiteModule(22411): Local module descriptor class for providerinstaller not found.
I/DynamiteModule(22411): Considering local module providerinstaller:0 and remote module providerinstaller:0
W/ProviderInstaller(22411): Failed to load providerinstaller module: No acceptable module found. Local version is 0 and remote version is 0.
W/DynamiteModule(22411): Local module descriptor class for providerinstaller not found.
I/DynamiteModule(22411): Considering local module providerinstaller:0 and remote module providerinstaller:0
W/ProviderInstaller(22411): Failed to load providerinstaller module: No acceptable module found. Local version is 0 and remote version is 0.
W/DynamiteModule(22411): Local module descriptor class for providerinstaller not found.
I/DynamiteModule(22411): Considering local module providerinstaller:0 and remote module providerinstaller:0
W/ProviderInstaller(22411): Failed to load providerinstaller module: No acceptable module found. Local version is 0 and remote version is 0.
Over LTE - When things work fine
Launching lib/main.dart on Pixel 4 XL in debug mode...
✓ Built build/app/outputs/apk/debug/app-debug.apk.
Connecting to VM Service at ws://127.0.0.1:54345/egB1v0JRe6c=/ws
W/DynamiteModule(23529): Local module descriptor class for providerinstaller not found.
I/DynamiteModule(23529): Considering local module providerinstaller:0 and remote module providerinstaller:0
W/ProviderInstaller(23529): Failed to load providerinstaller module: No acceptable module found. Local version is 0 and remote version is 0.
I/ore_network_bu(23529): The ClassLoaderContext is a special shared library.
I/chatty (23529): uid=10227(com.example.firestore_network_bug) AsyncTask #1 identical 1 line
I/ore_network_bu(23529): The ClassLoaderContext is a special shared library.
W/ore_network_bu(23529): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
W/ore_network_bu(23529): Accessing hidden method Lsun/misc/Unsafe;->arrayBaseOffset(Ljava/lang/Class;)I (greylist,core-platform-api, linking, allowed)
W/ore_network_bu(23529): Accessing hidden method Lsun/misc/Unsafe;->copyMemory(JJJ)V (greylist, linking, allowed)
W/ore_network_bu(23529): Accessing hidden method Lsun/misc/Unsafe;->objectFieldOffset(Ljava/lang/reflect/Field;)J (greylist,core-platform-api, linking, allowed)
W/ore_network_bu(23529): Accessing hidden method Lsun/misc/Unsafe;->getByte(J)B (greylist,core-platform-api, linking, allowed)
W/ore_network_bu(23529): Accessing hidden method Lsun/misc/Unsafe;->getByte(Ljava/lang/Object;J)B (greylist,core-platform-api, linking, allowed)
W/ore_network_bu(23529): Accessing hidden method Lsun/misc/Unsafe;->getLong(J)J (greylist,core-platform-api, linking, allowed)
W/ore_network_bu(23529): Accessing hidden method Lsun/misc/Unsafe;->putByte(JB)V (greylist,core-platform-api, linking, allowed)
W/ore_network_bu(23529): Accessing hidden method Lsun/misc/Unsafe;->putByte(Ljava/lang/Object;JB)V (greylist,core-platform-api, linking, allowed)
W/ore_network_bu(23529): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, reflection, allowed)
W/ore_network_bu(23529): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, reflection, allowed)
W/ore_network_bu(23529): Accessing hidden field Ljava/nio/Buffer;->address:J (greylist, reflection, allowed)
V/NativeCrypto(23529): Registering com/google/android/gms/org/conscrypt/NativeCrypto's 286 native methods...
W/ore_network_bu(23529): Accessing hidden method Ljava/security/spec/ECParameterSpec;->getCurveName()Ljava/lang/String; (greylist, reflection, allowed)
I/ProviderInstaller(23529): Installed default security provider GmsCore_OpenSSL
W/ore_network_bu(23529): Accessing hidden field Ljava/net/Socket;->impl:Ljava/net/SocketImpl; (greylist, reflection, allowed)
W/ore_network_bu(23529): Accessing hidden field Ljava/io/FileDescriptor;->descriptor:I (greylist, JNI, allowed)
W/ore_network_bu(23529): Accessing hidden method Ljava/security/spec/ECParameterSpec;->setCurveName(Ljava/lang/String;)V (greylist, reflection, allowed)
W/ore_network_bu(23529): Accessing hidden method Ldalvik/system/BlockGuard;->getThreadPolicy()Ldalvik/system/BlockGuard$Policy; (greylist,core-platform-api, linking, allowed)
W/ore_network_bu(23529): Accessing hidden method Ldalvik/system/BlockGuard$Policy;->onNetwork()V (greylist, linking, allowed)
I/flutter (23529): Document found!
I/flutter (23529): - {date: Timestamp(seconds=1590980400, nanoseconds=0), published: true, title: Hello World!, body: Firebase rocks and Firestore rocks also (when it works).}
I am trying to login with Twitter when i used dependency firebase_auth:^0.6.6 it was working perfactly and i fetch the user's Profile picture and the Code was
final TwitterLoginResult result = await twitterLogin.authorize();
switch (result.status)
{
case TwitterLoginStatus.loggedIn:
var session = result.session;
FirebaseUser user = await _auth.signInWithTwitter(
authToken: session.token, authTokenSecret: session.secret);
img=user.photoUrl;
}
but i migrated the app to AndroidX and this dependency was not compatible so i used firebase_auth: ^0.14.0+5 and this code was not working so i change the code to
final TwitterLoginResult result = await twitterLogin.authorize();
switch (result.status) {
case TwitterLoginStatus.loggedIn:
var session = result.session;
final AuthCredential credential =
TwitterAuthProvider.getCredential(authToken: session.token,
authTokenSecret: session.secret);
FirebaseUser user = (await _auth.signInWithCredential(credential)).user;
and this code is not working app is Crashing and showing the error
W/BiChannelGoogleApi(18829): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzak#70a4ccf
W/InputMethodManager(18829): startInputReason = 1
D/FirebaseAuth(18829): Notifying id token listeners about user ( D71yiiEX7ubSon4xxcddKlSydn72 ).
D/FirebaseAuth(18829): Notifying auth state listeners about user ( D71yiiEXccccccccKlSydn72 ).
I/zygote64(18829): Do full code cache collection, code=124KB, data=91KB
I/zygote64(18829): After code cache collection, code=123KB, data=68KB
I/zygote64(18829): Do partial code cache collection, code=123KB, data=68KB
I/zygote64(18829): After code cache collection, code=123KB, data=68KB
I/zygote64(18829): Increasing code cache capacity to 512KB
D/AndroidRuntime(18829): Shutting down VM
E/AndroidRuntime(18829): FATAL EXCEPTION: main
E/AndroidRuntime(18829): Process: com.example.login_app, PID: 18829
E/AndroidRuntime(18829): java.lang.IllegalArgumentException: Unsupported value: null
E/AndroidRuntime(18829): at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:294)
E/AndroidRuntime(18829): at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:291)
E/AndroidRuntime(18829): at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:291)
E/AndroidRuntime(18829): at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:291)
E/AndroidRuntime(18829): at io.flutter.plugin.common.StandardMethodCodec.encodeSuccessEnvelope(StandardMethodCodec.java:57)
E/AndroidRuntime(18829): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:225)
E/AndroidRuntime(18829): at io.flutter.plugins.firebaseauth.FirebaseAuthPlugin$SignInCompleteListener.onComplete(FirebaseAuthPlugin.java:691)
E/AndroidRuntime(18829): at com.google.android.gms.tasks.zzj.run(Unknown Source:4)
E/AndroidRuntime(18829): at android.os.Handler.handleCallback(Handler.java:808)
E/AndroidRuntime(18829): at android.os.Handler.dispatchMessage(Handler.java:101)
E/AndroidRuntime(18829): at android.os.Looper.loop(Looper.java:166)
E/AndroidRuntime(18829): at android.app.ActivityThread.main(ActivityThread.java:7529)
E/AndroidRuntime(18829): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(18829): at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
E/AndroidRuntime(18829): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
I/Process (18829): Sending signal. PID: 18829 SIG: 9
Lost connection to device.
Please can someone explain to me how to resolve this problem?
Problem is with login task AND Androidx twitter_login_issue
Add this dependency in your pubspec.yaml file and let me know this working or not?
flutter_twitter_login:
git: git://github.com/eudangeld/flutter_twitter_login.git
Same issue (question) login_issue
I'm using flutter_markdown: ^0.2.0 and I want to display an image saved on firebase firestorage.
If I try to display the markdown in my flutter widget:
class LessonScreen extends StatelessWidget {
const LessonScreen({this.lesson});
final Lesson lesson;
#override
Widget build(BuildContext context) {
return Scaffold(
body:
MarkdownBody(data: lesson.content));
}
}
My app crash.
I/flutter (25385): ══╡ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE ╞════════════════════════════════════════════════════
I/flutter (25385): The following _Exception was thrown resolving an image codec:
I/flutter (25385): Exception: HTTP request failed, statusCode: 403,
I/flutter (25385): https://firebasestorage.googleapis.com/v0/b/appname-db7de.appspot.com/o/image1.PNG?alt=media&token=xxxx
I don't have this problem with other images, but I have it only with the images saved on firestorage.
SOLVED
I have seen that the url that doesn't work is:
alt=media&token=xxxx
instead of
alt=media&token=xxxx
this is the link to flutter_markown repository issue.
I hope this fix will be available sooner or later
HTTP request failed, statusCode: 403 it means auth error.
You should check more detail about firebase store.
It's not about markdown stuff.
I had the same issue the problem was with the permission in the Firebase Storage so I change my Firebase Storage permission.
From
allow read, write: if request.auth != null;
To this
allow read, write;
I have asked a similar question Here.The new problem is that, after the internet address lookup('connected' is printed), but while the transaction is being run if the network is disconnected or when the network is very slow I get a timed out error exception which causes the app to crash.
try {
final result = await InternetAddress.lookup('google.com');
if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
print('connected');
Firestore.instance.runTransaction((transactionshere)async{
DocumentReference reference =
Firestore.instance.collection('One').document('two').collection('three').document('all_').collection('cur').document();
await reference.setData(dataToSend,merge: true);
});
}
} on SocketException catch (_) {
print('not connected');
_scafoldKey.currentState.showSnackBar(
SnackBar(content: Text("There was a problem check your connection"),duration: Duration(seconds: 4),),
);
}
error output:
I/flutter (24149): connected
W/Firestore(24149): (0.6.6-dev) [Firestore]: The behavior for java.util.Date objects stored in Firestore is going to change AND YOUR APP MAY BREAK.
W/Firestore(24149): To hide this warning and ensure your app does not break, you need to add the following code to your app before calling any other Cloud Firestore methods:
W/Firestore(24149):
W/Firestore(24149): FirebaseFirestore firestore = FirebaseFirestore.getInstance();
W/Firestore(24149): FirebaseFirestoreSettings settings = new FirebaseFirestoreSettings.Builder()
W/Firestore(24149): .setTimestampsInSnapshotsEnabled(true)
W/Firestore(24149): .build();
W/Firestore(24149): firestore.setFirestoreSettings(settings);
W/Firestore(24149):
W/Firestore(24149): With this change, timestamps stored in Cloud Firestore will be read back as com.google.firebase.Timestamp objects instead of as system java.util.Date objects. So you will also need to update code expecting a java.util.Date to instead expect a Timestamp. For example:
W/Firestore(24149):
W/Firestore(24149): // Old:
W/Firestore(24149): java.util.Date date = snapshot.getDate("created_at");
W/Firestore(24149): // New:
W/Firestore(24149): Timestamp timestamp = snapshot.getTimestamp("created_at");
W/Firestore(24149): java.util.Date date = timestamp.toDate();
W/Firestore(24149):
W/Firestore(24149): Please audit all existing usages of java.util.Date when you enable the new behavior. In a future release, the behavior will be changed to the new behavior, so if you do not follow these steps, YOUR APP MAY BREAK.
I/zygote (24149): The ClassLoaderContext is a special shared library.
I/zygote (24149): The ClassLoaderContext is a special shared library.
V/NativeCrypto(24149): Registering com/google/android/gms/org/conscrypt/NativeCrypto's 287 native methods...
D/NetworkSecurityConfig(24149): No Network Security Config specified, using platform default
I/ProviderInstaller(24149): Installed default security provider GmsCore_OpenSSL
W/System (24149): ClassLoader referenced unknown path: system/framework/mediatek-cta.jar
I/System.out(24149): e:java.lang.ClassNotFoundException: com.mediatek.cta.CtaHttp
W/System (24149): ClassLoader referenced unknown path: system/framework/mediatek-cta.jar
I/System.out(24149): e:java.lang.ClassNotFoundException: com.mediatek.cta.CtaHttp
W/System (24149): ClassLoader referenced unknown path: system/framework/mediatek-cta.jar
I/System.out(24149): e:java.lang.ClassNotFoundException: com.mediatek.cta.CtaHttp
W/System (24149): ClassLoader referenced unknown path: system/framework/mediatek-cta.jar