How to fix 'Dependency failing' when building Flutter application on Android - firebase

I am trying to use Google Sign in with my Flutter application. However, I am unable to build the application due to some issues with dependencies. I have updated all of my dependencies to the latest version but to no avail. How do I resolve these dependencies so I can build the application?
This is for a simple flutter application using google sign in running on a connected OnePlus 6 android phone.
I have tried updating my dependencies to the latest version as well as changing the code to match the latest version of the google_sign_in dependency found here: https://pub.dartlang.org/packages/google_sign_in
I also tried adding firebase_core to the list of dependencies as the error message said that the app relied on firebase_core. This did nothing to change the error message.
Project 'pubspec.yaml' dependencies
dependencies:
flutter:
sdk: flutter
duration: ^2.0.0
firebase_core: ^0.3.2
cloud_firestore: ^0.9.11
firebase_auth: ^0.8.4
google_sign_in: ^4.0.1+3
cupertino_icons: ^0.1.2
dev_dependencies:
flutter_test:
sdk: flutter
Project Level build.gradle (android/build.gradle):
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// Google Services class path
classpath 'com.google.gms:google-services:4.2.0'
}
}
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 Level build.gradle (android/app/build.gradle):
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.recipe_app"
minSdkVersion 21
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation 'com.google.firebase:firebase-core:16.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
apply plugin: 'com.google.gms.google-services'
The output of 'flutter run':
Launching lib/main.dart on ONEPLUS A6003 in debug mode...
Initializing gradle... 1.0s
Resolving dependencies... 4.0s
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
FAILURE: Build failed with an exception.
* What went wrong:
Failed to capture fingerprint of input files for task ':app:checkDebugClasspath' property 'compileClasspath' during up-to-date check.
> 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-stats:15.0.1 -> com.google.android.gms:play-services-basement#[
15.0.1], but play-services-basement version was 16.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 on project 'cloud_firestore' which depends onto com.google.firebase:firebase-firestore#18.2.0
-- Project 'app' depends onto com.google.firebase:firebase-core#16.0.1
-- Project 'app' depends on project 'firebase_auth' which depends onto com.google.firebase:firebase-auth#16.0.5
-- Project 'app' depends on project 'google_sign_in' which depends onto com.google.android.gms:play-services-auth#16.0.1
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
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 2.9s
Gradle task assembleDebug failed with exit code 1
I expected the application to build successfully so I could test if Google Sign in worked. However, the application does not build successfully and I am at a loss as to what to do.

I attempted to recompile using verbose mode and was informed about AndroidX being the cause.
I followed this link and downgraded all of the dependencies to the versions before the AndroidX migration as listed in the article. This fixed the issue.

Related

firebase_core throw this error when i start building the project

when i try to run the app it shows me this error
Launching lib\main.dart on sdk gphone x86 in debug mode...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
What went wrong: Could not determine the dependencies of task ':firebase_core:compileDebugAidl'.
Could not resolve all task dependencies for configuration ':firebase_core:debugCompileClasspath'.
Could not find com.google.firebase:firebase-common:.
Required by:
project :firebase_core
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 7s Exception: Gradle task assembleDebug failed with
exit code 1
i m using latest version of firebase_core
i have added firebse to my project
the build.gradle
rootProject.ext {
set('FlutterFire', [
FirebaseSDKVersion: '25.12.0'
])
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation platform('com.google.firebase:firebase-bom:28.2.1')
implementation "com.google.firebase:firebase-analytics"
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
.....
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"
classpath 'com.google.gms:google-services:4.3.8'
}
}
i resolved this problem by deleting
the
root.text of the firebase version it is in the
/build.gradle
and i built the project again.

Couldn't sync after adding depenency to gradle in VScode

I tried to configure my flutter project in order to use firebase. I added all the dependency and couldn't sync after adding the lines mentioned in the firebase to Gradle build.
How do I sync in vscode.
added depenency for firebase:
In project -> android -> app -> build.gradle :
apply plugin: 'com.google.gms.google-services'
In project -> gradle -> build.gradle:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
**classpath 'com.google.gms:google-services:4.3.3'**
}
IN project -> pubspec.yaml
firebase_auth: ^0.14.0+5
Also ran flutter pub get
Error log:
* Error running Gradle:
ProcessException: Process "C:\Users\LENOVO\Documents\flutter_apps\time_tracker_flutter_course\android\gradlew.bat" exited abnormally:
Starting a Gradle Daemon (subsequent builds will be faster)
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\LENOVO\Documents\flutter_apps\time_tracker_flutter_course\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 2m 23s
Command: C:\Users\LENOVO\Documents\flutter_apps\time_tracker_flutter_course\android\gradlew.bat app:properties
Please review your Gradle project setup in the android/ folder.
Exited (sigterm)
When using Firebase, you need to download the google-services.json file and add it to your project:
Where do I place Googleservices.json in Flutter app in order to solve 'google-services.json is missing'
Then in the android/build.gradle, you need to add the google() maven repository:
buildscript {
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
}
dependencies {
...
// Add this line
classpath 'com.google.gms:google-services:4.3.3'
}
}
allprojects {
...
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
...
}
}
and inside android\app\build.gradle, you need to add the google-service plugin:
apply plugin: 'com.google.gms.google-services'
Check this:
https://firebase.google.com/docs/flutter/setup?platform=android

* Error running Gradle: ProcessException: Process "E:\Flutter\login_demo\android\gradlew.bat" exited abnormally:

So guys i'am newbie at Flutter and i have my Flutter Project using Firebase Auth for user login. I have following the tutorial from youtube: https://www.youtube.com/watch?v=aaKef60iuy8 by guy called Andrea Bizzotto. I have follow 3 part of his videos regarding to this Firbase Auth tutorial. He suggest to latest firebase_auth dependecies, and according to pub.dev the latest dependecies of firebase_auth is
0.15.0+1, but he use the 0.5.4. However, if i use the 0.15.0+1 one i got some error at FirebaseAuth.instance, so i use the 0.5.4 dependecies. But it caused error to my gradle when building the project. The debug console throw me this:
[Debug Console Error Message][1]
And before make this post, i have tried to find any solution regarding to this error. So what have tried to do is:
Adding
classpath 'com.google.gms:google-services:4.3.2' and changing classpath 'com.android.tools.build:gradle:3.2.1' to
classpath 'com.android.tools.build:gradle:3.5.1' in (android/build.gradle)
Adding
multidexEnabled = true at defaultConfig, implementation 'com.google.firebase:firebase-analytics:17.2.0' implementation
'com.google.firebase:firebase-firestore:19.0.0' implementation
'com.android.support:multidex:1.0.3' at dependencies also apply
plugin: 'com.google.gms.google-services' at the bottom of
(android\app\buid.gradle) file
I'm also adding
android.useAndroidX=true
android.enableJetifier=true
org.gradle.daemon=true
org.gradle.parallel=true in gradle.properties file
Here is my flutter doctor -v result
[Flutter doctor -v Result][2]
Any Help is very much appreciated.
[1]: https://i.stack.imgur.com/60j9S.png [2]:
https://i.stack.imgur.com/9G8ug.png
you can try to update the build.grade from project root like this:
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"
classpath 'com.google.gms:google-services:4.3.3'
}
}
and then the distributionUrl in grade-wrapper.properties like this:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
I got the answer from here: https://github.com/flutter/flutter/issues/41492

Failed to capture fingerprint of input files for task ':app:preDebugBuild' property 'compileManifests' during up-to-date check

I'm setting firebase on my project and when I add inappmessaging-display lib this error appears:
Dependency resolved to an incompatible version:
Dependency(fromArtifactVersion=ArtifactVersion(groupId=com.google.firebase,
artifactId=firebase-messaging, version=17.3.2),
toArtifact=Artifact(groupId=com.google.firebase,
artifactId=firebase-iid), toArtifactVersionString=[17.0.2]) FAILURE:
Build failed with an exception.
What went wrong: Failed to capture fingerprint of input files for task ':app:preDebugBuild' property 'compileManifests' during
up-to-date check. In project 'app' a resolved Google Play services
library dependency depends on another at an exact version (e.g.
"[17.0. 2]", but isn't being resolved to that version. Behavior
exhibited by the library will be unknown.
Dependency failing: com.google.firebase:firebase-messaging:17.3.2 -> com.google.firebase:firebase-iid#[17.0.2], but fire base-iid version was 17.0.3.
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-iid#17.0.3 -- Project 'app' depends
onto com.google.firebase:firebase-messaging#17.3.2 -- Project 'app'
depends onto com.google.firebase:firebase-ads#17.1.2 -- Project
'app' depends onto
com.google.firebase:firebase-inappmessaging-display#17.0.4 --
Project 'app' depends onto
com.google.firebase:firebase-analytics#16.0.6 -- Project 'app'
depends onto com.google.firebase:firebase-analytics-impl#16.2.4 --
Project 'app' depends onto
com.google.firebase:firebase-inappmessaging#17.0.4 -- Project 'app'
depends onto com.google.firebase:firebase-core#16.0.6 -- Project
'app' depends onto
com.google.firebase:firebase-measurement-connector-impl#17.0.4 --
Project 'app' depends onto com.google.firebase:firebase-config#16.1.3
-- Project 'app' depends onto com.google.firebase:firebase-crash#16.2.1 -- Project 'app' depends
onto com.google.firebase:firebase-abt#16.0.1 -- Project 'app'
depends onto com.google.firebase:firebase-perf#16.2.3 -- Project
'app' depends onto
com.google.android.gms:play-services-measurement-api#16.0.4
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 build.gradle
file.
project file
buildscript {
ext.kotlin_version = '1.3.11'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.google.gms:google-services:4.2.0'
classpath ('com.google.firebase:firebase-plugins:1.1.5')
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
plugins {
id 'com.gradle.build-scan' version '1.16'
}
ext {
support_library_version = '28.0.0' //use the version of choice
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
app gradle file
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
buildScan {
licenseAgreementUrl = 'https://gradle.com/terms-of-service'
licenseAgree = 'yes'
}
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.myapp.pocapp"
minSdkVersion 25
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "com.android.support:animated-vector-drawable:$support_library_version"
implementation "com.android.support:exifinterface:$support_library_version"
implementation "com.android.support:cardview-v7:$support_library_version"
implementation "com.android.support:customtabs:$support_library_version"
implementation "com.android.support:support-media-compat:$support_library_version"
implementation "com.android.support:support-v4:$support_library_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "com.android.support:appcompat-v7:$support_library_version"
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
//Play services dependencies
implementation('com.google.android.gms:play-services-plus:15.0.1')
implementation('com.google.android.gms:play-services-gcm:15.0.1')
implementation('com.google.android.gms:play-services-maps:15.0.1')
implementation('com.google.android.gms:play-services-ads:15.0.1')
implementation('com.google.android.gms:play-services-location:15.0.1')
implementation('com.google.android.gms:play-services-analytics:16.0.3')
implementation('com.google.android.gms:play-services-basement:15.0.1')
implementation('com.google.android.gms:play-services-auth:16.0.0')
implementation('com.google.android.gms:play-services-drive:15.0.1')
//General google dependencies
implementation('com.android.installreferrer:installreferrer:1.0')
implementation('com.android.billingclient:billing:1.2')
//Firebase dependencies
implementation('com.google.firebase:firebase-core:16.0.6')
implementation('com.google.firebase:firebase-perf:16.2.3')
implementation('com.google.firebase:firebase-ads:17.1.2')
implementation('com.google.firebase:firebase-crash:16.2.1')
implementation('com.google.firebase:firebase-config:16.1.3')
implementation('com.google.firebase:firebase-messaging:17.3.2')
implementation('com.google.firebase:firebase-inappmessaging:17.0.4')
implementation('com.google.firebase:firebase-inappmessaging-display:17.0.4')
}
apply plugin: 'com.google.gms.google-services'
I already updated all libs to latest versions.
I am also facing same issue,
At finally got a Solution.
Please remove Cordova-plugin-firebase and
Use the latest major releases just by running: cordova plugin add cordova-plugin-firebase-lib
Simply follow the following link: https://www.npmjs.com/package/cordova-plugin-firebase-lib
Check your internet connection.
If you are connected,try to use a proxy server (using hotspot shield,PSiphone, etc.)
The problem was on firebase libs versions, Just update every lib to fix this.
cd android
./gradlew clean
try this

cloud_firestore and firebase_auth compatiblity issue in Flutter

I am developing a Flutter app. My app works fine with cloud_firestore and firebase_auth packages when I use them separately. However, when I include both of them together in my pubspecs.yaml file, the build fails and the following message is shown:
Note: /home/saber/Code/mobile_dev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.7.4/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: /home/saber/Code/mobile_dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.5.18/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /home/saber/Code/mobile_dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.5.18/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: /home/saber/Code/mobile_dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core-0.2.5/android/src/main/java/io/flutter/plugins/firebase/core/FirebaseCorePlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Here are the depenencies that I have in my pubspec.yaml file:
dependencies:
flutter:
sdk: flutter
firebase_auth: ^0.5.18
cloud_firestore: ^0.7.4
I checked the version of packages and they both seem to be at the latest version.
Any help on resolving this issue would be appreciated!
This might be connected to this issue, but I am not sure.
Update your gradle version. I was facing the same issue,i have solved it by using below steps.
Step 1:
in app/build.gradle
apply plugin: 'com.google.gms.google-services'
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
****multiDexEnabled true****
}
Step 2:
change gradle version dependencies in android/build.gradle
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.google.gms:google-services:3.2.0'
Step 3:
latest version of firebase_auth and cloud_firestore in pubspec.ymal
cloud_firestore: ^0.12.5+1
firebase_auth: ^0.11.1+6
google_sign_in: ^4.0.2
For me work just change the minSDKVersion to 23 in the app build.gradle.
You need to follow this setup:
Open android/app/build.gradle and add at the bottom of the file:
apply plugin: 'com.google.gms.google-services'
and in the android/build.gradle add the following:
buildscript {
repositories {
// ,,,
}
dependencies {
// ...
classpath 'com.google.gms:google-services:3.2.1'
}
}
Use only this dependencies in android/build.gradle and remove any other dependencies
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:3.2.1'
You have to use this versions in pubspec.yaml
firebase_auth: 0.5.11
google_sign_in: 3.0.4
cloud_firestore: 0.7.3
Because these versions have updated gradle tooling.
Following update should resolve the issue:
Update android/gradle/wrapper/gradle-wrapper.properties
to distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip
and update the dependencies and versions
in android/build.gradle
to dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.google.gms:google-services:4.3.2'
and android/build.gradle yet
buildscript {
ext.kotlin_version = '1.3.61'
in pubspec.yaml
firebase_core: ^0.4.2+1
cloud_firestore: ^0.12.11
Upgrade your gradle in app/build.gradle
run flutter pub upgrade to get latest dependencies !

Resources