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!
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'
}
today I was learning firebase and I got stuck while running the app.
following is the error that I got when I build the app after changes -:
Launching lib\main.dart on sdk gphone x86 arm in debug mode...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':firebase_core:javaPreCompileDebug'.
> Could not resolve all files for configuration ':firebase_core:debugCompileClasspath'.
> Could not find auto-value-annotations.jar (com.google.auto.value:auto-value-annotations:1.6.5).
Searched in the following locations:
https://jcenter.bintray.com/com/google/auto/value/auto-value-annotations/1.6.5/auto-value-annotations-1.6.5.jar
* 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
Exception: Gradle task assembleDebug failed with exit code 1
below are the file where I made changes and I assume that I did correctly as I am new to firebase and flutter -: 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 from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.flashchat"
minSdkVersion 16
targetSdkVersion 29
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 {
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'
}
and below is the android\build.gradle file
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.google.gms:google-services:4.3.4'
}
}
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
}
please help me with this...
below is the pubspec.yaml file
name: flashchat
description: A new Flutter application.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.1
firebase_core: ^0.5.3
firebase_auth: ^0.18.4
cloud_firestore: ^0.14.4
animated_text_kit: ^2.5.4
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- images/flash.png
- images/flash1.png
try to add this
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.game_app"
minSdkVersion 21
targetSdkVersion 30
multiDexEnabled true - !!!add this line
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
and also add multiDexEnabled imlimentation
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation platform('com.google.firebase:firebase-bom:27.1.0')
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.android.support:multidex:1.0.3' // add this line
}
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 am getting a google play services error in android studio and i am using flutter. I have tried various solutions but nothing seems to work.
I have tried to change the version of googleplayservices but its the same.
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-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 'cloud_firestore' which depends onto
com.google.firebase:firebase-firestore#17.1.1
-- Project 'app' depends on project 'firebase_storage' which depends onto
com.google.firebase:firebase-storage#15.+
-- 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.
build.gradle(app)
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 27
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID
(https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.news"
minSdkVersion 16
multiDexEnabled true
targetSdkVersion 27
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 {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
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.android.support:multidex:1.0.3'
}
apply plugin: 'com.google.gms.google-services'
build.gradle/project
buildscript {
ext.kotlin_version = '1.2.71'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.2.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
ext {
global_version_firebase = '16.0.+'
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
pubspec.yaml
name: news
description: 'A new Flutter application.'
version: 1.0.0+1
environment:
sdk: '>=2.0.0-dev.68.0 <3.0.0'
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
http: null
share: null
connectivity:
url_launcher:
cloud_firestore:
rxdart:
firebase_auth: ^0.5.19
google_sign_in:
date_format:
intl:
firebase_storage: ^0.3.7
image_picker:
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
assets:
- images/logo.jpg
- images/fb.jpg
- images/back.jpg
- images/google.jpg
please help me to solve this error.
Thank you
the issue actually stems from this one dependency here:
Project 'app' depends on project 'firebase_storage' which depends onto
com.google.firebase:firebase-storage#15.+
this means, that pubspec.yaml needs this one dependency updated:
firebase_storage: ^1.0.4
as the documentation states for 1.0.4 from Oct 12, 2018 bump Android dependencies to latest.