I am trying to use FirebaseAuth in a flutter application. I can use Firestore service but when i include firebase_auth depedency in pubspec.yaml file i got the following exception.
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
* Try:Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get
more log output.
* Get more help at https://help.gradle.org
here is my pubspec.yaml file
dependencies:
flutter:
sdk: flutter
intl: ^0.15.6
#firebase_core: ^0.2.2
google_sign_in:
git:
url: http://github.com/jahirhstu/flutter_plugins.git
path: packages/google_sign_in
#firebase_analytics:
# git:
# url: http://github.com/jahirhstu/flutter_plugins.git
# path: packages/firebase_analytics
firebase_auth:
git:
url: http://github.com/jahirhstu/flutter_plugins.git
path: packages/firebase_auth
cloud_firestore:
git:
url: http://github.com/jahirhstu/flutter_plugins.git
path: packages/cloud_firestore
cupertino_icons: ^0.1.0
shrine_images: 1.0.0
dev_dependencies:
flutter_test:
sdk: flutter
Well, I was trying to solve it and what I did was:
*1.-Reinstall Flutter
2.-Reinstall Dart SDK
3.-Download Gradle 5.1.1
4.-Create a new Application with Firebase and include dependencies
5.-Compile again*
And all of these didnt work.
Then I did:
6.-Copy next lines at the end of gradle.properties
android.useAndroidX=true
android.enableJetifier=true
7.-Changes on file app\build.gradle
android {
compileSdkVersion 28
...
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
multiDexEnabled true
...
}
}
8.-Optionally you can add code inside subproject{} in file android\build.gradle
subprojects {
...
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:deprecation" << "-Xlint:unchecked"
}
}
}
9.-Go to terminal and launch command
flutter clean
10.-Run your app.
Hope will be helpful
In your Project folder > android > app > build.gradle:
add the following Line in defaultConfig { .... multiDexEnabled true }
try doing this in the /android/app/build.gradle file:
android {
defaultConfig {
// ...
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
}
}
dependencies {
implementation 'com.android.support:multidex:1.0.3'
}
If none of the above technique works simply downgrade your gradle build level. This will solve your problem.
dependencies {
`classpath` '`com.android.tools.build:gradle:**3.5.0**`'
}
Related
This kind of error occurs, dom 25.12.0 not present on that location, and annotation did not change after changing its version.
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':generateReleaseRFile'.
> Could not resolve all files for configuration ':releaseRuntimeClasspath'.
> Could not find com.google.firebase:firebase-bom:25.12.0.
Searched in the following locations:
- https://storage.googleapis.com/download.flutter.io/com/google/firebase/firebase-
bom/25.12.0/firebase-bom-25.12.0.pom
- https://storage.googleapis.com/download.flutter.io/com/google/firebase/firebase-
bom/25.12.0/firebase-bom-25.12.0.jar
Required by:
project :
> Could not find com.google.firebase:firebase-core:.
Required by:
project :
> Could not find androidx.annotation:annotation:1.1.0.
Searched in the following locations:
-
https://storage.googleapis.com/download.flutter.io/androidx/annotation/annotation/1.1.0/annotation-
1.1.0.pom
-
https://storage.googleapis.com/download.flutter.io/androidx/annotation/annotation/1.1.0/annotation-
1.1.0.jar
Required by:
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.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':javaPreCompileRelease'.
> Could not resolve all files for configuration ':releaseCompileClasspath'.
> Could not find com.google.firebase:firebase-bom:25.12.0.
Required by:
project :
> Could not find com.google.firebase:firebase-core:.
Required by:
project :
> Could not find androidx.annotation:annotation:1.1.0.
Required by:
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 11s
The plugin firebase_core could not be built due to the issue above.
my pubspec.yml file:-
name: Dreamcart
description: A new Flutter application.
version: 2.1.0
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
cupertino_icons: ^1.0.0
cached_network_image: 2.2.0
fluttertoast: ^6.0.1
flutter_staggered_grid_view: 0.3.0
flutter_launcher_icons: ^0.8.0
mvc_pattern: ^3.4.1
global_configuration: ^1.3.0
http: ^0.12.0+2
intl: any
html: ^0.14.0+2
shared_preferences: ^0.5.3+4
flutter_html: ^0.10.4
flutter_svg: ^0.19.0
location: ^2.3.5
dynamic_theme: ^1.0.0
flutter_inappbrowser: ^1.2.2
url_launcher: ^5.4.1
firebase_messaging: ^7.0.0
firebase_analytics: ^4.0.2
razorpay_flutter: ^1.2.1
otp_screen: ^0.0.3
marquee: ^1.7.0
keyboard_actions: ^1.0.4
keyboard_avoider: ^0.1.2
flutter_typeahead: ^2.0.0
carousel_slider: ^3.0.0
speech_recognition: ^0.3.0+1
permission_handler: ^4.2.0
firebase_core: ^0.5.0
dev_dependencies:
flutter_test:
sdk: flutter
flutter_icons:
image_path: "assets/img/Dreamcartlogo.png"
android: "launcher_icon"
flutter:
assets:
- assets/cfg/
- assets/img/
- assets/img/visa.png
- assets/img/paypal.png
- assets/img/paypal2.png
- assets/img/apple_pay.png
- assets/img/brazil.png
- assets/img/canada.png
- assets/img/china.png
- assets/img/france.png
- assets/img/germany.png
- assets/img/italy.png
- assets/img/netherlands.png
- assets/img/spain.png
- assets/img/united-arab-emirates.png
- assets/img/united-states-of-america.png
- assets/img/marker.png
- assets/img/my_marker.png
- assets/img/mastercard.png
- assets/img/visacard.png
- assets/img/wallet.png
- assets/img/cash.png
- assets/img/pay_pickup.png
- assets/img/logo.png
- assets/img/loading.gif
- assets/img/loading_card.gif
- assets/img/loading_trend.gif
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
fonts:
- family: Poppins
fonts:
- asset: assets/fonts/Poppins-Thin.ttf
weight: 100
- asset: assets/fonts/Poppins-ExtraLight.ttf
weight: 200
- asset: assets/fonts/Poppins-Light.ttf
weight: 300
- asset: assets/fonts/Poppins-Regular.ttf
weight: 400
- asset: assets/fonts/Poppins-Medium.ttf
weight: 500
- asset: assets/fonts/Poppins-SemiBold.ttf
weight: 600
- asset: assets/fonts/Poppins-Bold.ttf
weight: 700
- asset: assets/fonts/Poppins-ExtraBold.ttf
weight: 800
- asset: assets/fonts/Poppins-Black.ttf
weight: 900
app/build.gradle file :-
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 = '9'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '2.1.0'
}
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystorePropertiesFile = rootProject.file("key.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
android {
compileSdkVersion 30
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID
(https://developer.android.com/studio/build/application-id.html).
applicationId "com.portalperfect.dreamcart"
minSdkVersion 19
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
minifyEnabled true
useProguard true
signingConfig signingConfigs.debug
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
}
flutter {
source '../..'
}
configurations.all {
resolutionStrategy {
force 'androidx.annotation:annotation:1.1.0'
}
}
dependencies {
implementation 'androidx.annotation:annotation:1.1.0'
implementation platform('com.google.firebase:firebase-bom:26.1.0')
implementation 'com.google.android.gms:play-services-base:15.0.2'
implementation "com.google.firebase:firebase-core:17.5.1"
implementation 'com.google.firebase:firebase-messaging:21.1.0'
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.android.support:multidex:1.0.3'
// Add the Firebase Crashlytics SDK.
}
apply plugin: 'com.google.gms.google-services'
android/build.gradle :-
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.google.gms:google-services:4.3.3'
}
}
allprojects {
repositories {
google()
center()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I tried so much but no solutions found for this issue. Help me out. Thank You.
Don't mention the version of firebase plugins or use updated version
I am trying to do a chat app and I included the
Firebase core, firebase auth and Firebase firestore.
When I run the app it shows the following errors. Do I need to post any other code files?
D8: Cannot fit requested classes in a single dex file (# methods: 91691 > 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:132)
at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:119)
at com.android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.java:102)
at com.android.build.gradle.internal.tasks.DexMergingTaskRunnable.run(DexMergingTask.kt:432)
at com.android.build.gradle.internal.tasks.Workers$ActionFacade.run(Workers.kt:242)
at org.gradle.workers.internal.AdapterWorkAction.execute(AdapterWorkAction.java:57)
at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:67)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:63)
at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:97)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1.lambda$execute$0(NoIsolationWorkerFactory.java:63)
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.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200)
at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195)
at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:62)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$call$2(DefaultBuildOperationExecutor.java:76)
at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.callWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:54)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:76)
at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:60)
at org.gradle.workers.internal.DefaultWorkerExecutor.lambda$submitWork$2(DefaultWorkerExecutor.java:200)
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, position: null
at Version.fakeStackEntry(Version_2.1.62.java:0)
at com.android.tools.r8.utils.Y.a(SourceFile:78)
at com.android.tools.r8.D8.run(D8.java:11)
at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:117)
... 36 more
Caused by: com.android.tools.r8.utils.b: Cannot fit requested classes in a single dex file (# methods: 91691 > 65536)
at com.android.tools.r8.utils.T0.error(SourceFile:1)
at com.android.tools.r8.utils.T0.a(SourceFile:2)
at com.android.tools.r8.dex.P.a(SourceFile:740)
at com.android.tools.r8.dex.P$h.a(SourceFile:7)
at com.android.tools.r8.dex.b.a(SourceFile:14)
at com.android.tools.r8.dex.b.b(SourceFile:25)
at com.android.tools.r8.D8.d(D8.java:133)
at com.android.tools.r8.D8.b(D8.java:1)
at com.android.tools.r8.utils.Y.a(SourceFile:36)
... 38 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 34s
[!] The shrinker may have failed to optimize the Java bytecode.
To disable the shrinker, pass the `--no-shrink` flag to this command.
To learn more, see: https://developer.android.com/studio/build/shrink-code
Exception: Gradle task assembleDebug failed with exit code 1
This is my pubspec.yml file where i included the dependencies in of the Firebase core,Firebase auth and Firebase firestore and others that are need for the project
name: flash_chat
description: A new Flutter project.
version: 1.0.0+1
environment:
sdk: ">=2.7.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
animated_text_kit: ^4.2.1
cloud_firestore: ^1.0.7
firebase_auth: ^1.1.2
firebase_core: ^1.1.0
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
This is a multidex issue, you have two solution, or you can set the minSDKVersion to 21 or add multidex in your dependencies in build.gradle:
https://developer.android.com/studio/build/multidex
android {
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 28
multiDexEnabled true
}
...
}
dependencies {
implementation "androidx.multidex:multidex:2.0.1"
}
Or just:
android {
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 28
}
...
}
Add Multi Dex :
Here is the Code : Go to 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"
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.example.bahokboy"
minSdkVersion 16
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
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 "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:multidex:1.0.3'
}
Started a new flutter project and trying to use firestore.
After following all step to add project to fire base.
Adding all plugins to pubspec.yaml and then running the project.
The log cat shows this:
04-04 14:54:56.061 24084-24084/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.firestoreflutterchat, PID: 24084
java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.example.firestoreflutterchat-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.firestoreflutterchat-2, /vendor/lib, /system/lib]]
at android.app.ActivityThread.installProvider(ActivityThread.java:4869)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4461)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4401)
at android.app.ActivityThread.access$1500(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1270)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5097)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.example.firestoreflutterchat-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.firestoreflutterchat-2, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.app.ActivityThread.installProvider(ActivityThread.java:4854)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4461)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4401)
at android.app.ActivityThread.access$1500(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1270)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5097)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method
Before adding cloud firestore plugin the newly project was running after adding this i am having issue.
This is the Pubspec.yaml file :
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cloud_firestore: ^0.13.4+2
permission_handler: ^5.0.0+hotfix.3
firebase_auth: ^0.15.5+3
google_sign_in: ^4.4.0
cupertino_icons: ^0.1.3
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
the problem did not resolve with multidex , only way was to remove it and follow this link
resolve multidex issue
it worked by removing these in your gradle
multiDexEnabled true
and
dependencies {
implementation 'com.android.support:multidex:1.0.3'
}
and changing from this
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
to this
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
useProguard true
}
debug{
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
and in your path: /android/app
right click and create a file named proguard-rules.pro
and put these files inside the file
#Flutter Wrapper
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.** { *; }
-keep class io.flutter.util.** { *; }
-keep class io.flutter.view.** { *; }
-keep class io.flutter.** { *; }
-keep class io.flutter.plugins.** { *; }
It seems some setups are still remaining for Firebase.
Checkout this link and set up the .json and .plist file accordingly in project.
If you further still facing the issue,
I would recommend some steps.
1) Delete all the build files of the project, invalid cache and restart android studio.
2) Follow the below changes in your project.
build.gradle file
android {
.....
defaultConfig {
......
multiDexEnabled true//add this line
}
......
dependencies{
compile 'com.android.support:multidex:1.0.1'//add this line
}
AndroidManifest.xml file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
....
<application
....
android:name="android.support.multidex.MultiDexApplication"
...>
<activity />
...
</application>
</manifest>
I am new to flutter development. I want to use the firebase database. I was able to connect to firebase using the firebase analytics plugin but I was not successful in using the firebase database.
I tried to add the plugin on a time to knew where did the issue come from and know I am sure it is the firebase_database plugin.
I have successfully added the following package:
firebase_core: ^0.4.0+9
firebase_analytics: ^5.0.2
firebase_auth: ^0.14.0+5
but when I add
firebase_database: ^3.1.0
I get the below error
Finished with error: Gradle task assembleDebug failed with exit code 1
This error appears when I run the default flutter application (The counter app) on my Android mobile.
So I open the Android module in Android Studio to get more details about the error.
I got the following error
ERROR: Unable to resolve dependency for ':firebase_database#debug/compileClasspath': Could not resolve android.arch.lifecycle:runtime:1.1.1.
Show Details
Affected Modules: firebase_database
ERROR: Unable to resolve dependency for ':firebase_database#debug/compileClasspath': Could not resolve android.arch.lifecycle:common:1.1.1.
Show Details
Affected Modules: firebase_database
ERROR: Unable to resolve dependency for ':firebase_database#debug/compileClasspath': Could not resolve android.arch.lifecycle:runtime:{strictly 1.0.0}.
Show Details
Affected Modules: firebase_database
ERROR: Unable to resolve dependency for ':firebase_database#debug/compileClasspath': Could not resolve android.arch.lifecycle:common:{strictly 1.0.0}.
Show Details
Affected Modules: firebase_database
ERROR: Failed to resolve: com.google.firebase:firebase-common:16.0.6
Show in Project Structure dialog
Affected Modules: firebase_database
ERROR: Unable to resolve dependency for ':firebase_database#debug/compileClasspath': Could not resolve android.arch.core:common:{strictly 1.0.0}.
Show Details
Affected Modules: firebase_database
ERROR: Unable to resolve dependency for ':firebase_database#debug/compileClasspath': Could not resolve android.arch.core:common:1.1.1.
Show Details
Affected Modules: firebase_database
ERROR: Unable to resolve dependency for ':firebase_database#debug/compileClasspath': Could not resolve android.arch.lifecycle:runtime:1.0.0.
Show Details
Affected Modules: firebase_database
This is my pubspec.yaml file
version: 1.0.0+1
environment:
sdk: ">=2.1.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: ^0.1.2
firebase_core: ^0.4.0+9
firebase_analytics: ^5.0.2
firebase_auth: ^0.14.0+5
firebase_database: ^3.1.0
dev_dependencies:
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
Also, below is my project level my build.gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
classpath 'com.google.gms:google-services:4.3.3'
}
}
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
}
Below is my app level 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 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.labstabs.riskometer"
minSdkVersion 21
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
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 {
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'
replace with this
classpath 'com.google.gms:google-services:4.2.0'
I'm working on a flutter application using firebase authentication system and Firestore. I worked for 3 months and I didn't encounter this error before. Now I published my application on play store and I found this error also for debug version with the emulator. I think to have configured properly the system because firebase worked for a while.
I think that this error occurs for all the apk that I builded after the upgrade of flutter.
Some suggestion to solve my problem?
Thanks
I enter my bundle ID on firebase and download the google-service.json file, copy and paste on android/app folder and build. I also tried to clean (as mentioned here https://github.com/flutter/flutter/issues/28003 ) and build the project and to enter some SHA1 and SHA-256 fingerprints to try if it was this the problem but I'm not sure which SHA1 enter on firebase. ReDownloaded the google-service.json and clean - build the project.
Other codes to initialise the FirebaseApp seems pretty old and I don't think that it can work for me like here (java.lang.IllegalStateException: FirebaseApp with name [DEFAULT]) .
I just authenticate a user using this code
user = await FirebaseAuth.instance
.signInWithEmailAndPassword(email: _email, password: _password);
and do some try catch to manage the output.
android/build.gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.google.gms:google-services:4.1.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "27.1.1"
}
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
android/app/build.gradle
android {
compileSdkVersion 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
applicationId "com.luxywebdesign.pocketstcw"
minSdkVersion 18
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
signingConfigs {
release {
storeFile file("my-release-key.keystore")
storePassword "StorePassword"
keyAlias "KeyAlias"
keyPassword "Password"
}
}
buildTypes {
release {
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.release
}
}
}
flutter {
source '../..'
}
dependencies {
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'
implementation 'com.google.firebase:firebase-core:16.0.1'
}
apply plugin: 'com.google.gms.google-services'
pubspec.yaml
environment:
sdk: ">=2.1.0 <3.0.0"
firebase_storage:
dependencies:
flutter:
sdk: flutter
firebase_auth: 0.8.2
file_picker: ^1.3.3
firebase_storage: ^2.1.0+1
firebase_core: 0.3.1+1
cloud_firestore: ^0.9.7
permission_handler: ^2.2.0
path_provider: ^0.5.0+1
http: ^0.12.0+1
url_launcher: ^5.0.2
open_file: ^2.0.1+2
datetime_picker_formfield: ^0.1.8
share:
git:
url: https://github.com/d-silveira/flutter-share.git
flutter_launcher_icons: ^0.7.0
image_picker: ^0.6.0+1
modal_progress_hud: ^0.1.3
flutter_keychain: ^1.0.0
pdf: ^1.3.7
image: ^2.0.7
flutter_local_notifications: ^0.6.1
auto_size_text: ^2.0.1
shared_preferences: ^0.5.3+1
Error message :
D/FirebaseApp(23461): Default FirebaseApp failed to initialize because no default options were found. This usually means that com.google.gms:google-services was not applied to your gradle project.
at the start after the installation of the apk and ...
E/MethodChannel#plugins.flutter.io/firebase_auth(23461): Failed to handle method call
E/MethodChannel#plugins.flutter.io/firebase_auth(23461): java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] doesn't exist.
E/MethodChannel#plugins.flutter.io/firebase_auth(23461): at com.google.firebase.FirebaseApp.getInstance(com.google.firebase:firebase-common##16.1.0:280)
E/MethodChannel#plugins.flutter.io/firebase_auth(23461): at io.flutter.plugins.firebaseauth.FirebaseAuthPlugin.getAuth(FirebaseAuthPlugin.java:76)
E/MethodChannel#plugins.flutter.io/firebase_auth(23461): at io.flutter.plugins.firebaseauth.FirebaseAuthPlugin.onMethodCall(FirebaseAuthPlugin.java:108)
E/MethodChannel#plugins.flutter.io/firebase_auth(23461): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222)
E/MethodChannel#plugins.flutter.io/firebase_auth(23461): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96)
E/MethodChannel#plugins.flutter.io/firebase_auth(23461): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:643)
E/MethodChannel#plugins.flutter.io/firebase_auth(23461): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#plugins.flutter.io/firebase_auth(23461): at android.os.MessageQueue.next(MessageQueue.java:326)
E/MethodChannel#plugins.flutter.io/firebase_auth(23461): at android.os.Looper.loop(Looper.java:160)
E/MethodChannel#plugins.flutter.io/firebase_auth(23461): at android.app.ActivityThread.main(ActivityThread.java:6669)
E/MethodChannel#plugins.flutter.io/firebase_auth(23461): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#plugins.flutter.io/firebase_auth(23461): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/MethodChannel#plugins.flutter.io/firebase_auth(23461): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I think the problem is you didn't make right the configuration settings. make sure to follow these steps :
Add your google-service.json file
Add apply plugin: 'com.google.gms.google-services' (app-level grade)
Add apply plugin: 'com.android.application' (app-level grade)
Add classpath 'com.google.gms:google-services:4.3.3' (project-level gradle)
After all this steps your problem should be solved. I also had the same problem once then I realise I didn't add step 2. Good Luck!