Flutter - Firebase Analytics Dependency Error - firebase

I have been building an app, and I wanted analytics in that so I added firebase_analytics: ^6.0.0 as a dependency. But whenever I try to run the app in debug mode, I get this error
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:mergeDebugJavaResource'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> File 'com.android.builder.files.ZipCentralDirectory#479a9b01' was deleted, but previous version not found in cache
* 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.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:mergeDebugNativeLibs'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> File 'com.android.builder.files.ZipCentralDirectory#3cbd23b5' was deleted, but previous version not found in cache
* 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.
But if I remove it, it runs in debug mode without any problems.
So far, I ran flutter clean and then flutter pub get, and also tried Invalidating the cache and restarting, but neither of those worked.
Here's my pubspec.yaml excluding firebase_analytics
cupertino_icons: ^0.1.3
firebase_core: ^0.5.0
firebase_auth: ^0.18.0+1
cloud_firestore: ^0.14.0+2
fluttertoast: ^7.1.1
intl_phone_number_input: ^0.5.1

Related

Flutter build fails [Execution failed for "cloud_firestore-3.1.12".]

**FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring project ':cloud_firestore'.
Could not load compiled classes for build file 'C:\src\flutter.pub-cache\hosted\pub.dartlang.org\cloud_firestore-3.1.12\android\build.gradle' from cache.
Failed to notify project evaluation listener.
Could not get unknown property 'android' for project ':cloud_firestore' of type org.gradle.api.Project.
Could not find method implementation() for arguments [project ':firebase_core'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Could not get unknown property 'android' for project ':cloud_firestore' of type org.gradle.api.Project.
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 3s
Exception: Gradle task assembleDebug failed with exit code 1**
my current flutter project which uses the following firebase packages
cloud_firestore: ^3.1.12
firebase_core: ^1.14.1
firebase_auth: ^3.3.14
firebase_storage: ^10.2.12
firebase_messaging: ^11.2.13

Build failed when I try to run my flutter app

I attached what I got in debug console when I try to run my app.
These are my firebase dependencies
firebase_core: ^1.12.0
firebase_auth: ^3.3.8
cloud_firestore: ^3.1.9
Launching lib\main.dart on ***** in debug mode...
/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_platform_interface-6.2.0/lib/src/method_channel/utils/exception.dart:14:11: Error: Method not found: 'Error.throwWithStackTrace'.
Error.throwWithStackTrace(exception, stackTrace);
^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_platform_interface-6.2.0/lib/src/method_channel/utils/exception.dart:17:9: Error: Method not found: 'Error.throwWithStackTrace'.
Error.throwWithStackTrace(
^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_platform_interface-6.2.0/lib/src/method_channel/utils/exception.dart:12:7: Error: A non-null value must be returned since the return type 'Never' doesn't allow null.
Never convertPlatformException(Object exception, StackTrace stackTrace) {
^
FAILURE: Build failed with an exception.
* Where:
Script 'C:\src\flutter\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 991
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\flutter\flutter\bin\flutter.bat'' finished with non-zero exit value 1
* 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 21s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
I have tried many methods, But they didn't work.
try flutter clean and then flutter run it work for me
flutter version 2.10.4
My first guess is that you might not finish platform-specific installation/setup for Firebase as well as Firebase plugins.
Just to verify that You can visit the FlutterFire website which will guide you through the installation steps for the targeting platforms for Firebase and plugin setup;
Otherwise, the flutter clean and flutter pub get should do the trick.
However, a problem still exists, you can restart your editor and just run the command flutter pub get/ flutter pub upgrade.

FLUTTER: java.io.StreamCorruptedException: File format not recognised

One moment the project was running fine but when i tried to debug the code again i got this error.
Launching lib\main.dart on SM A515F in debug mode... lib\main.dart:1
FAILURE: Build failed with an exception.
* What went wrong:
java.io.StreamCorruptedException: File format not recognised
* 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
Can you run
flutter clean
followed by
flutter pub get
then
flutter run

Getting error while adding firebase analytics in flutter app

Got this error after adding firebase_analytics in pubsec.yaml file.
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':firebase_core:compileDebugAidl'.
> The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[16.5.0,16.5.0]], but resolves to 16.0.3. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
* 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 5s
Finished with error: Gradle task assembleDebug failed with exit code 1
these are dependencies in pubsec.yaml
dependencies:
firebase_analytics:
cloud_firestore:
graphql_flutter: ^1.0.0
firebase_auth:
firebase_core:
mobx: ^0.1.2
flutter_mobx: ^0.1.1
mobx_codegen: ^0.1.0+1
carousel_pro: ^0.0.13
cupertino_icons: ^0.1.2
flutter:
sdk: flutter
thanks
I'm unable to replicate the behavior you've reported at present. Per checking the comments, it looks like that the issue has been solved. Running flutter clean should also solve most conflicts caused in the dependencies cache. 

Flutter: Can't update the firebase_auth package from 0.5.11 to 0.6.6

I'm trying to update the package in order to solve this problem. When I change the firebase_auth version on my pubspec.yaml I obtain this:
error
Configure project :firebase_auth
Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':firebase_auth'.
> Could not open cp_proj remapped class cache for 1hd54il9uhc3eutyaybhw2pq0
(~/.gradle/caches/4.10.2/scripts-remapped/build_7iuv4c9gs2g2ad3uvhc3eae18/1hd54il9uhc3eutyaybhw2pq0/cp_proj70b1361a260e0ceb212a59c45f680ebd).
> Unexpected lock protocol found in lock file. Expected 3, found 0.
* 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 0s
Command: ~/git-repo/mine-repo/printer_products/android/gradlew app:properties
Please review your Gradle project setup in the android/ folder.
pubspec
dependencies:
flutter:
sdk: flutter
#firebase_auth: ^0.5.11
firebase_auth: ^0.6.6
google_sign_in: ^3.0.4
firebase_core: ^0.2.5+1
cloud_firestore: ^0.7.3
firebase_storage: ^1.0.4
image_picker: ^0.4.10
http: ^0.12.0
uuid: ^1.0.3
mime: ^0.9.6+2
shared_preferences: "^0.4.3"
rxdart: "^0.19.0"
scoped_model: "^1.0.1"
Seems that only the combination of firebase_auth: 0.5.11 and google_sign_in: 3.0.4 works.
When I realized that the problem was not caused directly by the package and its update, I found the solution on this question. I simply removed the cache mentioned on the error: rm -rf ~/.gradle/caches/4.10.2

Resources