Flutter app crashes when it use Firestore plugin in Release mode - firebase

Everything works perfectly when in debug mode. It first happened when I update Flutter version to 1.10.x I could not remember which version did I use, properly. It should be 1.7.8, it was stable. To fix it I downgrade the flutter to 1.7.8+4 and also downgrade firebase related pub packages. But error still here.
Stack Trace for Related Error, captured from gogle play console
java.lang.RuntimeException:
at com.google.firebase.firestore.util.AsyncQueue.a (AsyncQueue.java:379)
at com.google.firebase.firestore.util.AsyncQueue$$Lambda$5.run (AsyncQueue.java:2)
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:7000)
at java.lang.reflect.Method.invoke (Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:441)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1408)
Caused by: java.lang.AbstractMethodError:
at com.google.protobuf.GeneratedMessageLite.a (GeneratedMessageLite.java:1319)
at com.google.firebase.firestore.proto.WriteBatch.s (WriteBatch.java:120)
at com.google.firebase.firestore.proto.WriteBatch.a (WriteBatch.java:162)
at com.google.firebase.firestore.proto.WriteBatch.a (WriteBatch.java:15)
at com.google.firebase.firestore.proto.WriteBatch$Builder.a (WriteBatch.java:835)
at com.google.firebase.firestore.local.LocalSerializer.a (LocalSerializer.java:172)
at com.google.firebase.firestore.local.SQLiteMutationQueue.a (SQLiteMutationQueue.java:188)
at com.google.firebase.firestore.local.LocalStore.a (LocalStore.java:237)
at com.google.firebase.firestore.local.LocalStore$$Lambda$2.get (LocalStore.java:8)
at com.google.firebase.firestore.local.SQLitePersistence.a (SQLitePersistence.java:195)
at com.google.firebase.firestore.local.LocalStore.a (LocalStore.java:201)
at com.google.firebase.firestore.core.SyncEngine.a (SyncEngine.java:227)
at com.google.firebase.firestore.core.FirestoreClient.a (FirestoreClient.java:200)
at com.google.firebase.firestore.core.FirestoreClient$$Lambda$11.run (FirestoreClient.java:6)
at com.google.firebase.firestore.util.AsyncQueue.a (AsyncQueue.java:311)
at com.google.firebase.firestore.util.AsyncQueue$$Lambda$4.call (AsyncQueue.java:2)
at com.google.firebase.firestore.util.AsyncQueue.a (AsyncQueue.java:287)
at com.google.firebase.firestore.util.AsyncQueue$$Lambda$3.run (AsyncQueue.java:4)
at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:457)
at java.util.concurrent.FutureTask.run (FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run
(ScheduledThreadPoolExecutor.java:301)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:636)
at com.google.firebase.firestore.util.AsyncQueue$DelayedStartFactory.run (AsyncQueue.java:205)
at java.lang.Thread.run (Thread.java:764)
When I saw the error trace on device (in android crash report dialog) It mentioned Firebase 19.0.0
Flutter Doctor:
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel unknown, v1.7.8+hotfix.4, on Microsoft Windows [Version 10.0.17134.1069], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Enterprise 2017 15.9.7)
[√] Android Studio (version 3.4)
[√] VS Code, 64-bit edition (version 1.38.1)
[√] Connected device (3 available)
• No issues found!
Error reporoducing scenario for final describe:
Build app with flutter run --release
App try an basic firestore call
Firestore.instance.collection('collection-name').document('docuemnt-id').get()
App crashes.
Also getting the same error with building with flutter build appbudle

Here is the solution of my nightmare.
EDIT:
Error
FATAL EXCEPTION: main
Process: com.app.android, PID: 12668
java.lang.RuntimeException: Internal error in Firestore (19.0.0).
at com.google.firebase.firestore.g.j.a(:379)
at com.google.firebase.firestore.g.g.run(Unknown Source:2)
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:6718)
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:858)
To fix this error, update android.enableR8=false in gradle.properties. You need to add this row cause default value true.

I was facing the same problem, and the following changes to my build.gradle solved it.
android {
compileSdkVersion 28
...
buildTypes {
release {
shrinkResources false
minifyEnabled false
signingConfig signingConfigs.release
}
}
}
Reference: https://github.com/FirebaseExtended/flutterfire/issues/1412#issuecomment-570161645
N.B. I know its not a perfect solution to disable minify. But it seems the firebase team is working on it and will be resolved in future update

I was able to keep android.enableR8=true by upgrading the gradle version.
android/build.gradle
from:
classpath 'com.android.tools.build:gradle:3.2.1'
to:
classpath 'com.android.tools.build:gradle:3.5.0'
android/gradle/wrapper/gradle-wrapper.properties
from:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
to:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

I have a similar case (same error), so I'll try to tell you what happened and maybe is the same issue that you have.
In my case I lost the keystore, so I pass through all the process of ask for a new key and so on, after that I publish a new version and my app crash in the exact way of yours, after a lot of google and stuff I figured out that have something to do with the signature (because works in debug but do not work in release), so I get into the firebase console and download again the google-services.json file, and surprise... the file have a block that wasn't there before.
After that, I test in a device with the command that you provide here (by the way thanks!), and woala! It works.
I also update the SHA-1 Signature key in the console, so that may help too.
I hope that my response help you to come out to some solution.

https://github.com/flutter/flutter/issues/41576
changing to version 3.4.2 i.e com.android.tools.build:gradle:3.4.2 in build.gradle(project) , worked for me.

Related

Flutter web exception caught by widget library (but only in debug). "Cannot read properties of undefined..."

We have a strange error that occurs intermittently in our Flutter Web app. When I say intermittent, I mean when you run the app through "flutter run -d chrome" 50% of the time it will work, and 50% of the time the app will halt with this error:
"The following JSNoSuchMethodError was thrown building _ScaffoldMessengerScope:
TypeError: Cannot read properties of undefined (reading 'AnimationController')"
I bolded the "AnimationController" here because it is not always the same object. The object that errors out varies from run to run. And it's usually not the same object.
The other strange thing is that if I build the project and then deploy the build/web folder to a web server, and load the app from there, the error does not occur. This is a problem that happens strictly when executing "flutter run -d chrome". It happens on every engineer's machine too. Some of us run Macs and some are on Windows. Everyone has the same issue, although not everyone has it at the same frequency. Some see it happen once or twice an hour, and others see it almost every run.
Doing a "flutter clean" does not solve the problem.
We thought the issue could be related to our use of firebase through the Flutterfire package because we saw there were some related issues posted by other users on Stackoverflow. But so far updating the package, re-installing the package, and commenting out the firebase script inclusions in the index.html do not seem to solve the issue.
Flutter doctor output seems nominal as well:
[✓] Flutter (Channel stable, 2.8.1, on macOS 12.1 21C52 darwin-arm, locale en-US)
• Flutter version 2.8.1 at /Users/hreddy/Code/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 77d935af4d (5 weeks ago), 2021-12-16 08:37:33 -0800
• Engine revision 890a5fca2e
• Dart version 2.15.1
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/hreddy/Library/Android/sdk
• Platform android-31, build-tools 30.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.10.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
[✓] VS Code (version 1.63.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.32.0
[✓] Connected device (1 available)
• Chrome (web) • chrome • web-javascript • Google Chrome 97.0.4692.99
• No issues found!
The full output when the error occurs is as follows (you can see in this run it again occurred for a different random object):
TypeError: Cannot read properties of undefined (reading 'FirebaseFirestoreWeb')
at Object.registerPlugins (http://localhost:4999/packages/wiijii_visuals/generated_plugin_registrant.dart.lib.js:27:25)
at main (http://localhost:4999/web_entrypoint.dart.lib.js:31:35)
at main.next (<anonymous>)
at runBody (http://localhost:4999/dart_sdk.js:40211:34)
at Object._async [as async] (http://localhost:4999/dart_sdk.js:40242:7)
at main$ (http://localhost:4999/web_entrypoint.dart.lib.js:30:18)
at http://localhost:4999/main_module.bootstrap.js:19:10
at Array.forEach (<anonymous>)
at window.$dartRunMain (http://localhost:4999/main_module.bootstrap.js:18:32)
at <anonymous>:1:8
at Object.runMain (http://localhost:4999/dwds/src/injected/client.js:8709:21)
at http://localhost:4999/dwds/src/injected/client.js:23792:19
at _wrapJsFunctionForAsync_closure.$protected (http://localhost:4999/dwds/src/injected/client.js:3511:15)
at _wrapJsFunctionForAsync_closure.call$2 (http://localhost:4999/dwds/src/injected/client.js:11510:12)
at Object._asyncStartSync (http://localhost:4999/dwds/src/injected/client.js:3475:20)
at main__closure3.$call$body$main__closure (http://localhost:4999/dwds/src/injected/client.js:23804:16)
at main__closure3.call$1 (http://localhost:4999/dwds/src/injected/client.js:23731:19)
at StaticClosure._rootRunUnary (http://localhost:4999/dwds/src/injected/client.js:3873:18)
at _CustomZone.runUnary$2$2 (http://localhost:4999/dwds/src/injected/client.js:12858:39)
at _CustomZone.runUnaryGuarded$1$2 (http://localhost:4999/dwds/src/injected/client.js:12805:14)
at _ForwardingStreamSubscription._sendData$1 (http://localhost:4999/dwds/src/injected/client.js:12395:19)
at _ForwardingStreamSubscription._add$1 (http://localhost:4999/dwds/src/injected/client.js:12341:15)
at _ForwardingStreamSubscription._add$1 (http://localhost:4999/dwds/src/injected/client.js:12674:12)
at _MapStream._handleData$2 (http://localhost:4999/dwds/src/injected/client.js:12735:12)
at _ForwardingStreamSubscription._handleData$1 (http://localhost:4999/dwds/src/injected/client.js:12700:20)
at BoundClosure.eval (eval at Closure_forwardCallTo (http://localhost:4999/dwds/src/injected/client.js:1439:14), <anonymous>:3:44)
at StaticClosure._rootRunUnary (http://localhost:4999/dwds/src/injected/client.js:3873:18)
at _CustomZone.runUnary$2$2 (http://localhost:4999/dwds/src/injected/client.js:12858:39)
at _CustomZone.runUnaryGuarded$1$2 (http://localhost:4999/dwds/src/injected/client.js:12805:14)
at _ControllerSubscription._sendData$1 (http://localhost:4999/dwds/src/injected/client.js:12395:19)
at _ControllerSubscription._add$1 (http://localhost:4999/dwds/src/injected/client.js:12341:15)
at _SyncStreamController._sendData$1 (http://localhost:4999/dwds/src/injected/client.js:12189:32)
at _SyncStreamController.add$1 (http://localhost:4999/dwds/src/injected/client.js:12070:15)
at BoundClosure.eval (eval at Closure_forwardInterceptedCallTo (http://localhost:4999/dwds/src/injected/client.js:1519:14), <anonymous>:3:45)
at StaticClosure._rootRunUnary (http://localhost:4999/dwds/src/injected/client.js:3873:18)
at _CustomZone.runUnary$2$2 (http://localhost:4999/dwds/src/injected/client.js:12858:39)
at _CustomZone.runUnaryGuarded$1$2 (http://localhost:4999/dwds/src/injected/client.js:12805:14)
at _ControllerSubscription._sendData$1 (http://localhost:4999/dwds/src/injected/client.js:12395:19)
at _ControllerSubscription._add$1 (http://localhost:4999/dwds/src/injected/client.js:12341:15)
at _SyncStreamController._sendData$1 (http://localhost:4999/dwds/src/injected/client.js:12189:32)
at _SyncStreamController.add$1 (http://localhost:4999/dwds/src/injected/client.js:12070:15)
at _GuaranteeSink.add$1 (http://localhost:4999/dwds/src/injected/client.js:23287:25)
at HtmlWebSocketChannel_closure1.call$1 (http://localhost:4999/dwds/src/injected/client.js:23556:149)
at _EventStreamSubscription_closure.call$1 (http://localhost:4999/dwds/src/injected/client.js:17826:26)
at StaticClosure._rootRunUnary (http://localhost:4999/dwds/src/injected/client.js:3879:16)
at _CustomZone.runUnary$2$2 (http://localhost:4999/dwds/src/injected/client.js:12858:39)
at _CustomZone.runUnaryGuarded$1$2 (http://localhost:4999/dwds/src/injected/client.js:12805:14)
at _CustomZone_bindUnaryCallbackGuarded_closure.call$1 (http://localhost:4999/dwds/src/injected/client.js:12995:25)
at invokeClosure (http://localhost:4999/dwds/src/injected/client.js:1262:26)
at WebSocket.<anonymous> (http://localhost:4999/dwds/src/injected/client.js:1281:18)
Any idea what direction we should investigate further?
The solution for me is when I first run the flutter app on my IDE, I hit the refresh button on the browser where the app runs and won't encounter it again until I close my IDE.

flutter firebase facebook login not working on android due to a build.gradle problem

it is working fine on iOS but facing this issue on android
Launching lib/main.dart on sdk gphone x86 arm in debug mode...
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':firebase_auth:generateDebugRFile'.
Could not resolve all files for configuration ':firebase_auth:debugCompileClasspath'.
Could not find com.facebook.android:facebook-login:[8.1).
Required by:
project :firebase_auth
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 20s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
The version given by the facebook documentation doesn't work for me either.
That's the version i am actually using:
implementation 'com.facebook.android:facebook-login:[8,9)'
Anyway, if it doesn't solve your problem, try to give more information like, the plugin you are using for the facebook authentication, its version, and the firebase_auth and firebase_core version of the plugin you are using
It just worked with me when i switched to windows (don't know how ) and the error still show on Mac OS after trying all available solutions

Flutter: Java uses or overrides a deprecated API

I've been trying to use the auth, firestore firebase in an Android / IOS flutter application, and have been experiencing many different issues, after testing several different versions. Now it's showing me several messages in the build log.
build log
Note:
D:\Flutter\SDK\flutter.pub-cache\hosted\pub.dartlang.org\firebase_core-0.4.3+1\android\src\main\java\io\flutter\plugins\firebase\core\FirebaseCorePlugin.java
uses or overrides a deprecated API. Note: Recompile with
-Xlint:deprecation for details. Note: D:\Flutter\SDK\flutter.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.13.0+1\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java
uses unchecked or unsafe operations. Note: Recompile with
-Xlint:unchecked for details. D8: Cannot fit requested classes in a single dex file (# methods: 81454 > 65536)
com.android.builder.dexing.DexArchiveMergerException: Error while
merging dex archives: The number of method references in a .dex file
cannot exceed 64K. Learn how to resolve this issue at
https://developer.android.com/tools/building/multidex.html
at com.android.builder.dexing.D8DexArchiveMerger.getExceptionToRethrow(D8DexArchiveMerger.java:131)
at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:118)
at com.android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.java:102)
at com.android.build.gradle.internal.tasks.DexMergingTaskRunnable.run(DexMergingTask.kt:444)
at com.android.build.gradle.internal.tasks.Workers$ActionFacade.run(Workers.kt:335)
at org.gradle.workers.internal.AdapterWorkAction.execute(AdapterWorkAction.java:50)
at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:47)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1$1.create(NoIsolationWorkerFactory.java:65)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1$1.create(NoIsolationWorkerFactory.java:61)
at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:98)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.execute(NoIsolationWorkerFactory.java:61)
at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44)
at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:56)
at org.gradle.workers.internal.DefaultWorkerExecutor$3.call(DefaultWorkerExecutor.java:215)
at org.gradle.workers.internal.DefaultWorkerExecutor$3.call(DefaultWorkerExecutor.java:210)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:215)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:164)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:131)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
at java.lang.Thread.run(Thread.java:748) Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to
complete
at com.android.tools.r8.utils.t.a(:55)
at com.android.tools.r8.D8.run(:11)
at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:116)
... 34 more Caused by: com.android.tools.r8.utils.AbortException: Error: null, Cannot fit
requested classes in a single dex file (# methods: 81454 > 65536)
at com.android.tools.r8.utils.Reporter.a(:21)
at com.android.tools.r8.utils.Reporter.a(:7)
at com.android.tools.r8.dex.VirtualFile.a(:33)
at com.android.tools.r8.dex.VirtualFile$h.a(:5)
at com.android.tools.r8.dex.ApplicationWriter.a(:13)
at com.android.tools.r8.dex.ApplicationWriter.write(:35)
at com.android.tools.r8.D8.d(:44)
at com.android.tools.r8.D8.b(:1)
at com.android.tools.r8.utils.t.a(:23)
... 36 more
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':app:mergeDexDebug'.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 4m 33s
flutter doctor -v
[√] Flutter (Channel stable, v1.12.13+hotfix.5, on Microsoft Windows
[Version 10.0.18362.535], locale en-IN)
• Flutter version 1.12.13+hotfix.5 at D:\Flutter\SDK\flutter
• Framework revision 27321ebbad (3 weeks ago), 2019-12-10 18:15:01 -0800
• Engine revision 2994f7e1e6
• Dart version 2.7.0
[√] Android toolchain - develop for Android devices (Android SDK
version 29.0.2)
• Android SDK at C:\Users\admin\AppData\Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• Java binary at: D:\Android SDK\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
• All Android licenses accepted.
[√] Android Studio (version 3.5)
• Android Studio at D:\Android SDK
• Flutter plugin version 41.1.2
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
pubspec
dependencies:
flutter:
sdk: flutter
firebase_auth: ^0.15.3
cloud_firestore: ^0.13.0+1
build.gradle(android)
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.0'
}
You need to use the following plugin:
dependencies:
firebase_auth: ^0.15.3
cloud_firestore: ^0.13.0+1
Don't forget to configure firebase:
https://pub.dev/packages/cloud_firestore#setup
https://pub.dev/packages/firebase_auth#usage
Also in your app/build.gradle, increase the minSdkVersion:
Change this:
minSdkVersion 16
into this:
minSdkVersion 23
In order to use minSdkVersion below 21 you will have to configure your app for multidex like this:
android {
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 28
multiDexEnabled true
}
...
}
dependencies {
implementation "androidx.multidex:multidex:2.0.1"
}
After this please run the
flutter pub upgrade
flutter pub get
flutter clean
flutter run
It will still throw the warning after flutter clean, but at least it will be possible for supporting earlier versions.
More to check out on official docs

Can't integrate Firebase with my application

When I integrate Firebase with my app, Build failed with an exception.
Although the first error that occurred was a gradle update, i've tried and i still get an error while running gradle.
Because there was no error in the code and the amount of coding was too much, I can only show error messages.
Error running Gradle:
ProcessException: Process "C:\Users\82109\AndroidStudioProjects\instargram_clon\android\gradlew.bat" exited abnormally:
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details
Configure project :app
WARNING: API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()'.
It will be removed at the end of 2019.
For more information, see d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getMergeResources(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getJavaCompile(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
WARNING: API 'variant.getMergeAssets()' is obsolete and has been replaced with 'variant.getMergeAssetsProvider()'.
It will be removed at the end of 2019.
For more information, see d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getMergeAssets(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
WARNING: API 'variantOutput.getProcessResources()' is obsolete and has been replaced with 'variantOutput.getProcessResourcesProvider()'.
It will be removed at the end of 2019.
For more information, see d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variantOutput.getProcessResources(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
*********************************************************
WARNING: This version of image_picker will break your Android build if it or its dependencies aren't compatible with AndroidX.
See goo.gl/CP92wY for more information on the problem and how to fix it.
This warning prints for all Android build failures. The real root cause of the error may be unrelated.
*********************************************************
Command: C:\Users\82109\AndroidStudioProjects\instargram_clon\android\gradlew.bat app:properties
Finished with error: Please review your Gradle project setup in the android/ folder.
※ When integrating Firebase with my app, I'm wondering if several versions are all up-to-date. This is because i have optionally and randomly changed to the latest version.
for firebase you can integrate your app manually see firebase documentation
for a quick answer follow this steps:android
Create a Firebase project
Register your app with Firebase
Add a Firebase configuration file (google-services.json)
Add Firebase SDKs to your app
WARNING: This version of image_picker will break your Android build if it or its dependencies aren't compatible with AndroidX => update your image_picker

Android Studio Tools -> Firebase doesn't work, IDE Error occuring

When I try to open the Firebase assistent in Tools > Firebase an IDE Error occurs.
I've already tried to reinstall the Google Repository needed for this tool, reactivating the firebase plugins, and also reinstalled Android Studio (though without deleting all user settings).
Android Studio 3.1.3
Build #AI-173.4819257, built on June 4, 2018
JRE: 1.8.0_152-release-1024-b02 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
IDE Error:
Exeption in plugin Firebase Services. Moments ago. Occured 2 times since last clear. Undread. Disable Plugin.
null
java.util.NoSuchElementException
at com.google.common.collect.Iterators$1.next(Iterators.java:81)
at com.google.services.firebase.DependencyStateManager.getDependencyState(DependencyStateManager.java:60)
at com.google.services.firebase.DependencyStateManager.init(DependencyStateManager.java:109)
at com.android.tools.idea.assistant.view.StatefulButton.<init>(StatefulButton.java:122)
at com.android.tools.idea.assistant.view.TutorialStep.<init>(TutorialStep.java:106)
at com.android.tools.idea.assistant.view.TutorialCard.redraw(TutorialCard.java:153)
at com.android.tools.idea.assistant.view.TutorialCard.<init>(TutorialCard.java:90)
at com.android.tools.idea.assistant.view.FeaturesPanel.<init>(FeaturesPanel.java:84)
at com.android.tools.idea.assistant.AssistSidePanel.<init>(AssistSidePanel.java:81)
at com.android.tools.idea.assistant.AssistToolWindowFactory.createToolWindowContent(AssistToolWindowFactory.java:37)
at com.android.tools.idea.assistant.OpenAssistSidePanelAction.lambda$openWindow$0(OpenAssistSidePanelAction.java:59)
at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:315)
at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.runNextEvent(LaterInvocator.java:424)
at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:407)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:762)
at java.awt.EventQueue.access$500(EventQueue.java:98)
at java.awt.EventQueue$3.run(EventQueue.java:715)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:732)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:822)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:650)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:366)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
A quick search brought up the following procedure to fix the issue:
go to Settings > Plugins.
remove all Firebase plugins.
restart Android Studio.
back to Settings > Plugins.
enable the Firebase plugins again.
restart Android Studio.

Resources