Flutter Firebase Auth not working in Ecommerce app - firebase

I was trying out the firebase auth but when I added the dependencies I got some error.
Could you please check what the error?
This is the error that I got :
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:processDebugResources'.
Android resource linking failed
Output: D:\App\dipam\build\app\intermediates\incremental\mergeDebugResources\merged.dir\values-v28\values-v28.xml:7: error: resource android:attr/dialogCornerRadius not found.
And this the dependencies that I added to the pubspec.yaml file :
dependencies:
flutter:
sdk: flutter
carousel_slider: ^1.0.1
cloud_firestore: 0.8.2+3
firebase_auth: 0.6.6
google_sign_in: ^3.2.4
shared_preferences:
fluttertoast:

The error you posted is a result of conflicting android.support and AndroidX versions. Make sure you're targeting API version 28.
In your app's build.gradle check if you have following values set
android {
compileSdkVersion 28 // <-- Make sure you target API 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// ...
targetSdkVersion 28 // <-- You need to update this value as well, or you might encounter runtime errors
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
// ...
}
// ...
}
Also, make sure your not using old android.support libraries in your dependencies, but new AndroidX packaged. Check this article for further references

Related

FlutterSomePackagePlugin.java uses or overrides a deprecated API

This problem has given two solutions changing minSdkVersion to 23 and setting multiDexEnabled to true, on the internet but none worked for me,
when I run flutter run --no-sound-null-safety I get this error
Note: C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core-1.7.0\android\src\main\java\io\flutter\plugins\firebase\core\FlutterFirebaseCorePlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-2.5.3\android\src\main\java\io\flutter\plugins\firebase\firestore\FlutterFirebaseFirestorePlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-2.5.3\android\src\main\java\io\flutter\plugins\firebase\firestore\streamhandler\TransactionStreamHandler.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\geocoder-0.2.1\android\src\main\java\com\aloisdeniel\geocoder\GeocoderPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\google_maps_flutter-2.0.9\android\src\main\java\io\flutter\plugins\googlemaps\Convert.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\google_maps_flutter-2.0.9\android\src\main\java\io\flutter\plugins\googlemaps\TileProviderController.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\libphonenumber-2.0.2\android\src\main\java\com\codeheadlabs\libphonenumber\LibphonenumberPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 190.1s
√ Built build\app\outputs\flutter-apk\app-debug.apk.
Installing build\app\outputs\flutter-apk\app.apk... 9.4s
D/FlutterLocationService(28465): Creating service.
D/FlutterLocationService(28465): Binding to location service.
Syncing files to device SM A207F... 272ms
but the package build on my phone.
the packages which are deprecated are already in their latest versions
this is pubspec.yml
version: 1.0.0+1
environment:
sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
flutter_spinkit: ^5.1.0
shared_preferences: ^2.0.6
http: ^0.13.3
percent_indicator: ^3.0.1
js: ^0.6.3
flutter_google_places: ^0.3.0
intl: ^0.17.0
google_maps_webservice: ^0.0.20-nullsafety.5
progress_indicators: ^1.0.0
smooth_star_rating: ^1.1.1
email_validator: ^2.0.1
dropdown_search: ^1.0.3
intl_phone_number_input: ^0.7.0+2
pinput: ^1.2.0
stripe_payment: ^1.1.4
flutter_html: ^2.1.0
location: ^4.3.0
google_maps_flutter: ^2.0.9
firebase_database: ^8.0.0
firebase_core: ^1.7.0
cloud_firestore: ^2.5.3
dio: ^4.0.0
flutter_polyline_points: ^1.0.0
geocoder: ^0.2.1
table_calendar: ^3.0.2
url_launcher: ^6.0.10
dev_dependencies:
flutter_test:
sdk: flutter
enabling multidex could not solve my problem.
this is android/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"
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 30
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.tingsapp.customers"
minSdkVersion 23
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
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 "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.guava:guava:27.0.1-android'
implementation 'com.google.firebase:firebase-analytics'
}
this is flutter doctor
PS C:\Users\amu\Desktop\projects\mobile apps\tingsapp-customer\customer> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.2.2, on Microsoft Windows [Version 10.0.19041.1165], locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[√] Chrome - develop for the web
[√] Android Studio (version 4.0)
[√] VS Code (version 1.61.1)
[√] Connected device (3 available)
! Doctor found issues in 1 category.
this is flutter --version
PS C:\Users\amu\Desktop\projects\mobile apps\tingsapp-customer\customer> flutter --version
Flutter 2.2.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision d79295af24 (4 months ago) • 2021-06-11 08:56:01 -0700
Engine • revision 91c9fc8fe0
Tools • Dart 2.13.3
any helps please,

A newer version of the firebase_core FlutterFire plugin is required, please update your firebase_core pubspec dependency

I am getting this error when trying to build a Flutter project in VSCode. The same project worked before but now it stoped working.
FAILURE: Build completed with 2 failures.
-----------
* Where:
Build file 'C:\Fltr\DevSoftware\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-2.5.2\android\build.gradle' line: 28
* What went wrong:
A problem occurred evaluating project ':cloud_firestore'.
> A newer version of the firebase_core FlutterFire plugin is required, please update your firebase_core pubspec dependency.
* 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:
A problem occurred configuring project ':cloud_firestore'.
> compileSdkVersion is not specified. Please add it to build.gradle
* 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 730ms
Line 28 of build.gradle is marked by .. , its the last line here:
def firebaseCoreProject = findProject(':firebase_core')
if (firebaseCoreProject == null) {
throw new GradleException('Could not find the firebase_core FlutterFire plugin, have you added it as a dependency in your pubspec?')
} else if (!firebaseCoreProject.properties['FirebaseSDKVersion']) {
**throw new GradleException('A newer version of the firebase_core FlutterFire plugin is required, please update your firebase_core pubspec dependency.')**
}
this is the important part of my pubspec.yaml:
environment:
sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
package_info_plus: ^1.0.6
package_info_plus_web: ^1.0.4
cached_network_image: ^3.1.0
cloud_firestore: ^2.5.2
cloud_functions: ^3.0.3
firebase_auth: ^3.1.1
firebase_core: ^1.6.0
firebase_crashlytics: ^2.2.1
firebase_messaging: ^10.0.7
flutter_svg: ^0.22.0
font_awesome_flutter: ^9.1.0
get: ^4.3.8
get_storage: ^2.0.3
google_place: ^0.4.3
in_app_review: ^2.0.3
percent_indicator: ^3.0.1
syncfusion_flutter_sliders: ^19.2.60
url_launcher: ^6.0.10
webview_flutter: ^2.0.13
dev_dependencies:
flutter_test:
sdk: flutter
Anyone an idea how to solve it? I have tried different package versions. I have deleted some cache folders like described in other stack overflow links. But no solution yet.
It worked with this command:
flutter pub cache repair
open build.gradle in android/app and set minSdkVersion 21
like that :
defaultConfig {
minSdkVersion 21
}
flutter pub cache repair
It worked for me after updating all the dependencies by running 'flutter pub cache repair' only this in terminal

Getting proguard error on adding androidx biometric API ( "androidx.biometric:biometric:1.0.1")

I am getting following error on building release apk after adding androidx biometric api "androidx.biometric:biometric:1.0.1" in gradle file
Caused by: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
../release/values-v28/values-v28.xml:7: error: resource android:attr/dialogCornerRadius not found.
../release/values-v28/values-v28.xml:11: error: resource android:attr/dialogCornerRadius not found.
../release/values/values.xml:2853: error: resource android:attr/fontVariationSettings not found.
../release/values/values.xml:2854: error: resource android:attr/ttcIndex not found.
error: failed linking references.
I am using below mentioned sdk / tools version
buildToolsVersion = '28.0.3'
compileSdkVersion 28
targetSdkVersion 28
I am able to build debug apk and it works fine
I created my app following the instructions given here and here. And I have no problems creating and running a release APK. Here is the proguard section of my Gradle file
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

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

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.

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