Could not determine the dependencies of task ':app:preDebugBuild' - firebase

I am build an app with firebase dependencies before creating an app i have done the firebase configuration and added firebase dependencies in pubspec.yaml. But when i run the app i got some errors.
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:preDebugBuild'.
> In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[15.0.
1]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.
Dependency failing: com.google.android.gms:play-services-flags:15.0.1 -> com.google.android.gms:play-services-basement#[
15.0.1], but play-services-basement version was 16.0.1.
The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art
ifact with the issue.
-- Project 'app' depends on project 'firebase_auth' which depends onto com.google.firebase:firebase-auth#16.0.2
-- Project 'app' depends on project 'firebase_core' which depends onto com.google.firebase:firebase-core#16.0.4
-- Project 'app' depends on project 'firebase_database' which depends onto com.google.firebase:firebase-database#15.+
For extended debugging info execute Gradle from the command line with ./gradlew --info :app:assembleDebug to see the dep
endency paths to the artifact. This error message came from the google-services Gradle plugin, report issues at https://
github.com/google/play-services-plugins and disable by adding "googleServices { disableVersionCheck = false }" to your b
uild.gradle file.
* 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 2s
Finished with error: Gradle task assembleDebug failed with exit code 1

The Problem occur when the dependencies cannot download from jcenter server. change your network connection follows flutter clean and try again
you can still work in debug mode
flutter run --debug will work
or you can goto File > Settings>Build,Execution,Deployment>Build Tools>Gradle>Uncheck Offline work option in Android Studio
You can also invalidate Cache and Restart

Related

Flutter:The plugin firebase_auth could not be built due to the issue above

I just use firebase_auth package to send me code by phone Number. it work fine in debug mode but when I try to get apk it show me this error. can anyone help me please?
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':sms:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
C:\Users\Mohammad Asef\.gradle\caches\transforms-2\files-2.1\8014592fef965c457f4d96ed4583a915\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/fontVariationSettings not found.
C:\Users\Mohammad Asef\.gradle\caches\transforms-2\files-2.1\8014592fef965c457f4d96ed4583a915\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/ttcIndex not found.
* 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 3m 52s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 233.5s (!)
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the
incompatibility.
Building plugin firebase_auth...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 0.3s
Exception in thread "main" java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:225)
at java.util.zip.ZipFile.<init>(ZipFile.java:155)
at java.util.zip.ZipFile.<init>(ZipFile.java:169)
at org.gradle.wrapper.Install.unzip(Install.java:214)
at org.gradle.wrapper.Install.access$600(Install.java:27)
at org.gradle.wrapper.Install$1.call(Install.java:74)
at org.gradle.wrapper.Install$1.call(Install.java:48)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
at org.gradle.wrapper.Install.createDist(Install.java:48)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
The plugin firebase_auth could not be built due to the issue above.
firebase_auth is using AndroidX libraries, but your flutter project is still using the old android support library. To solve this upgrade to flutter latest version. From the docs:
How do I know if my project is using AndroidX?
Starting from Flutter v1.12.13, new projects created with flutter create -t <project-type> use AndroidX by default.
Projects created prior to this Flutter version must not depend on any old build artifact or old Support Library class.
In an app or module project, the file android/gradle.properties or .android/gradle.properties must contain:
android.useAndroidX=true
android.enableJetifier=true
https://flutter.dev/docs/development/androidx-migration
I solved it by adding firebase_analytics dependency in pubspec, then adding manually string value of default_notification_channel_id in android resource just like below
<string name="default_notification_channel_id" translatable="false">fcm_default_channel</string>

Firebase ML Kit

Trying to use Firebase ml kit for label but getting error below with version; firebase_ml_vision: ^0.9.10
Error
Launching lib\main.dart on sdk gphone x86 arm in debug mode...
lib\main.dart
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[19.0.
2]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.
Dependency failing: com.google.android.gms:play-services-vision:20.0.0 -> com.google.android.gms:play-services-vision-co
mmon#[19.0.2], but play-services-vision-common version was 19.1.0.
The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art
ifact with the issue.
-- Project 'app' depends onto com.google.firebase:firebase-ml-vision#{strictly 24.1.0}
-- Project 'app' depends on project 'firebase_ml_vision' which depends onto com.google.firebase:firebase-ml-vision#20.0.
0
-- Project 'app' depends onto com.google.android.gms:play-services-vision-common#{strictly 19.1.0}
-- Project 'app' depends onto com.google.firebase:firebase-bom#26.2.0
-- Project 'app' depends onto com.google.android.gms:play-services-vision-image-label#{strictly 18.0.4}
-- Project 'app' depends onto com.google.firebase:firebase-bom#{strictly 26.2.0}
-- Project 'app' depends onto com.google.android.gms:play-services-vision#{strictly 20.0.0}
For extended debugging info execute Gradle from the command line with ./gradlew --info :app:assembleDebug to see the dep
endency paths to the artifact. This error message came from the google-services Gradle plugin, report issues at https://
github.com/google/play-services-plugins and disable by adding "googleServices { disableVersionCheck = true }" to your bu
ild.gradle file.
* 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
BU�LD FAILED in 13s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
After searching on github, somehow with edit below, app is running now, but when i try to use mlkit, getting error below
Edit 2
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation platform('com.google.firebase:firebase-bom:26.0.0')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.android.support:multidex:1.0.3'
api 'com.google.firebase:firebase-ml-vision-face-model:20.0.2'
implementation 'com.google.android.gms:play-services-vision:20.1.1'
implementation 'com.google.android.gms:play-services-vision-common:19.1.1'
implementation 'com.google.android.gms:play-services-vision-image-label:18.0.5'
implementation 'com.google.android.gms:play-services-vision-face-contour-internal:16.0.2'
}
Error in App
D/MediaScannerConnection( 8393): Scanned /storage/emulated/0/Android/data/com.example.temp_name/files/Pictures/e235923b-70f9-404a-aa0b-930333cceea96952909717190624838.jpg to null
I/flutter ( 8393): /storage/emulated/0/Android/data/com.example.temp_name/files/Pictures/scaled_e235923b-70f9-404a-aa0b-930333cceea96952909717190624838.jpg
W/DynamiteModule( 8393): Local module descriptor class for com.google.android.gms.vision.dynamite.ica not found.
I/DynamiteModule( 8393): Considering local module com.google.android.gms.vision.dynamite.ica:0 and remote module com.google.android.gms.vision.dynamite.ica:0
W/DynamiteModule( 8393): Local module descriptor class for com.google.android.gms.vision.ica not found.
I/DynamiteModule( 8393): Considering local module com.google.android.gms.vision.ica:0 and remote module com.google.android.gms.vision.ica:0
E/Vision ( 8393): Error loading optional module com.google.android.gms.vision.ica: com.google.android.gms.dynamite.DynamiteModule$LoadingException: No acceptable module found. Local version is 0 and remote version is 0.
W/LabelerNativeHandle( 8393): Native handle not yet available. Reverting to no-op handle.
Since you're including firebase-bom:26.2.0, that determines the versions of all Firebase SDKs you use. So remove the version numbers from all other Firebase SDK dependencies in your build.gradle to get rid of the version conflict.

Build Failing with an exception when adding firebase_auth or cloud_firestore in the pubspec.yaml file (firebase_core is working):

From the run terminal of android studio:
FAILURE: Build failed with an exception.
Where:
Script 'C:\Flutter\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 362
What went wrong:
A problem occurred configuring project ':cloud_firestore_web'.
Could not find method implementation() for arguments [project ':firebase_core'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
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.
Similar issue with firebase_auth.
Had a similar problem recently, here are the steps that fixed it for me.
Run flutter pub upgrade to upgrade all the Firebase plugins to the latest versions.
Use the steps at https://firebase.flutter.dev/docs/migration to check for any deprecated code.
In the android/build.gradle file, make sure the google services dependency is classpath 'com.google.gms:google-services:4.3.3' or whatever the latest version is.
In the android/app/build.gradle file, if you have any dependencies of the form
implementation 'com.google.firebase:[firebase-product:version-number] then get rid of those lines
Run flutter clean

Using physical device to run simple firebase flutter app and getting gradle errors

Launching lib\main.dart on Redmi 5 Plus in debug mode...
Initializing gradle...
Resolving dependencies...
* Error running Gradle:
ProcessException: Process "C:\user\proj\android\gradlew.bat" exited
abnormally:
Starting a Gradle Daemon, 2 incompatible and 1 stopped Daemons could not be
reused, use --status for details
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\user\proj\android\app\build.gradle' line: 24
* What went wrong:
A problem occurred evaluating project ':app'.
ASCII
* 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 3m 22s
Command: C:\user\proj\android\gradlew.bat app:properties
Finished with error: Please review your Gradle project setup in the android/
folder.
But if I comment apply plugin: 'com.google.gms.google-services' in proj/app/build.gradle it will work perfectly but than firebase is not working.
I hope you write this all dependencies in your file
like
CHECK My Github file
Have you added the google-services.json at the right location? (with app-level build.gradle)
Also, check if you have these as dependency in project level build.gradle
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.2.0'

Execution failed for task ':firebase_auth:compileDebugJavaWithJavac'

After upgrading firebase_auth from earlier version to ^0.8.0+1 generates error for me.
Here is error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':firebase_auth:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* 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 2s
Finished with error: Gradle task assembleDebug failed with exit code 1
According to the Changelog, you have to perform a migration in the Android project to AndroidX.
The details of the changes required are here.
See CHANGELOG:
0.8.0
Breaking change. Migrate from the deprecated original Android Support Library to AndroidX. This shouldn't result in any functional changes, but it requires any Android apps using this plugin to also migrate if they're using the original support library.
Firstly set the compileSdkVersion to 28 in the android/app/build.gradle file.
Secondly add the following to your android/gradle.properties file:
android.useAndroidX=true
android.enableJetifier=true

Resources