Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[all] Flutter Android build fails with firebase dependencies. #17

Closed
erluxman opened this issue Aug 23, 2019 · 35 comments
Closed

[all] Flutter Android build fails with firebase dependencies. #17

erluxman opened this issue Aug 23, 2019 · 35 comments
Labels
impact: critical Usually a production crash with high user impact. (P1) impact: crowd Affects many people, though not necessarily a specific customer with an assigned label. (P2) platform: android Issues / PRs which are specifically for Android. platform: ios Issues / PRs which are specifically for iOS. type: bug Something isn't working

Comments

@erluxman
Copy link

erluxman commented Aug 23, 2019

I am using Android Studio 3.5 stable

java -version 1.8

and this is the issue :

I have project gradle like this :

buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
        classpath 'com.google.gms:google-services:4.3.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 gradle like this :

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.takefun.android"
        minSdkVersion 16
        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 {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    implementation 'com.android.support:multidex:1.0.3'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

apply plugin: 'com.google.gms.google-services'

& Pubspec.yaml like this :

name: Name
description: Expense.

version: 1.0.0+1

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
   flutter:
     sdk: flutter
  cupertino_icons: ^0.1.2
  image_picker: ^0.6.0+17
  cloud_firestore: ^0.12.9
  firebase_auth: ^0.14.0+2
  firebase_core: ^0.4.0+8
  google_sign_in: ^4.0.6
  fimber: ^0.3.2
  gradient_widgets: ^0.5.0
  flutter_svg: ^0.13.1
  flutter_vector_icons: ^0.2.0
  image_cropper: ^1.0.2
  firebase_storage: ^3.0.5
  stack_trace: ^1.9.3


dev_dependencies:
  flutter_test:
    sdk: flutter


My iOS builds runs well but my android build is failing with console output :

Launching lib/main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Resolving dependencies...
Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
   > Could not find com.google.database.firebase:database.firebase-firestore:19.0.0.
     Required by:
         project :app > project :cloud_firestore
   > Could not find com.google.database.firebase:database.firebase-core:16.0.9.
     Required by:
         project :app > project :firebase_core

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 51s
Finished with error: Gradle task assembleDebug failed with exit code 1

Flutter doctor has the following output (just listed android and android studio related ones):


[✓] Flutter (Channel stable, v1.7.8+hotfix.4, on Mac OS X 10.14.6 18G87, locale en-US)
    • Flutter version 1.7.8+hotfix.4 at /Users/adventure/dev/flutter
    • Framework revision 20e59316b8 (5 weeks ago), 2019-07-18 20:04:33 -0700
    • Engine revision fee001c93f
    • Dart version 2.4.0

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/adventure/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 28.0.3
    • Java binary at: /Applications/Android Studio 3.5.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Android Studio (version 3.5)
    • Android Studio at /Applications/Android Studio 3.5.app/Contents
    • Flutter plugin version 38.2.3
    • Dart plugin version 191.8423
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] Android Studio (version 3.4)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 37.1.1
    • Dart plugin version 183.6270
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

 
@arudp

This comment has been minimized.

@idurvesh
Copy link

I am facing it as well. It stops recognizing the GradleException inside of a build.gradle

@ghost
Copy link

ghost commented Aug 26, 2019

I had a similar error. Adding this at the bottom of android/app/build.gradle solved the problem temporarily for me, maybe it will work for you too:

apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true

@NoamDev
Copy link
Contributor

NoamDev commented Aug 26, 2019

Hey @erluxman, try changing classpath 'com.google.gms:google-services:4.3.0'
in your project gradle.build to classpath 'com.google.gms:google-services:3.2.1'

let me know if it worked for you

@erluxman
Copy link
Author

erluxman commented Aug 29, 2019

I had a similar error. Adding this at the bottom of android/app/build.gradle solved the problem temporarily for me, maybe it will work for you too:

apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true

I tried that but I get this error
A problem occurred evaluating project ':app'.

No such property: config for class: com.google.gms.googleservices.GoogleServicesPlugin

@erluxman
Copy link
Author

Hey @erluxman, try changing classpath 'com.google.gms:google-services:4.3.0'
in your project gradle.build to classpath 'com.google.gms:google-services:3.2.1'

let me know if it worked for you

Did not work

@NoamDev
Copy link
Contributor

NoamDev commented Aug 29, 2019

Yeah, I wasn't sure it'll work.
I have another idea, try to add in the end of depndencies(){}
those two lines

implementation 'firebase-core:16.0.9'
implementation 'com.google.firebase:firebase-firestore:19.0.0'

@erluxman
Copy link
Author

erluxman commented Sep 11, 2019

Yeah, I wasn't sure it'll work.
I have another idea, try to add in the end of depndencies(){}
those two lines

implementation 'firebase-core:16.0.9'
implementation 'com.google.firebase:firebase-firestore:19.0.0'

Did not help :(

@Babiosik
Copy link

I have similar problem with firebase_auth. On line
await _auth.signInWithCredential(credential)
app crashed with error java.lang.IllegalArgumentException: Unsupported value: null

@NoamDev
Copy link
Contributor

NoamDev commented Sep 17, 2019

@erluxman
I'm sorry, my mistake, could you try this instead?
If it doesn't work, could publish the new android build log so I can know if the problem was partially solved?

implementation 'com.google.firebase:firebase-core:16.0.9'
implementation 'com.google.firebase:firebase-firestore:19.0.0'

@BondarenkoStas BondarenkoStas added the type: bug Something isn't working label Sep 23, 2019
@lakwsh01
Copy link

With same problem when import firebase_database
classpath 'com.android.tools.build:gradle:3.2.1'
classpath com.google.gms:google-services:3.2.1

and in
gradle.properties add
android.useAndroidX=true
android.enableJetifier=true

Seems everything goes to normal.

@samdx
Copy link

samdx commented Oct 13, 2019

Hey @erluxman, try changing classpath 'com.google.gms:google-services:4.3.0'
in your project gradle.build to classpath 'com.google.gms:google-services:3.2.1'

let me know if it worked for you

Cloned an old repo, and this really helped.

@iapicca iapicca changed the title Flutter Android build fails with firebase dependencies. [all] Flutter Android build fails with firebase dependencies. Oct 23, 2019
@iapicca iapicca added the impact: crowd Affects many people, though not necessarily a specific customer with an assigned label. (P2) label Oct 23, 2019
@iapicca
Copy link

iapicca commented Oct 23, 2019

Hi @erluxman
did the proposed solution fix the issue?
If didn't and you are still experiencing this issue
with the latest version of Flutter and FlutterFire plugin
can you please provide your updated flutter doctor -v
and your and your flutter run --verbose/flutter build --verbose ?
Also, to better address the issue, would be helpful
if you could post a self contained app on github
or the steps to reproduce it.
Thank you

@satsin06
Copy link

satsin06 commented Jun 3, 2020

Hey @erluxman, try changing classpath 'com.google.gms:google-services:4.3.0'
in your project gradle.build to classpath 'com.google.gms:google-services:3.2.1'

let me know if it worked for you
Still not working

@DBSumation
Copy link

Got the same issue:

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    classpath 'com.android.tools.build:gradle:3.3.2'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath 'com.google.gms:google-services:3.2.1'

}

Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

  • Where:
    Build file '/Users/ed/AndroidStudioProjects/flutter_app/android/app/build.gradle' line: 66

  • What went wrong:
    A problem occurred evaluating project ':app'.

Could not find method classpath() for arguments [com.android.tools.build:gradle:3.3.2] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

@dhikshithrm
Copy link

@erluxman
I'm sorry, my mistake, could you try this instead?
If it doesn't work, could publish the new android build log so I can know if the problem was partially solved?

implementation 'com.google.firebase:firebase-core:16.0.9'
implementation 'com.google.firebase:firebase-firestore:19.0.0'

i have same issue i didnt help

@dhikshithrm
Copy link

Got the same issue:

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    classpath 'com.android.tools.build:gradle:3.3.2'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath 'com.google.gms:google-services:3.2.1'

}

Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

  • Where:
    Build file '/Users/ed/AndroidStudioProjects/flutter_app/android/app/build.gradle' line: 66
  • What went wrong:
    A problem occurred evaluating project ':app'.

Could not find method classpath() for arguments [com.android.tools.build:gradle:3.3.2] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

same problem bro

@erluxman
Copy link
Author

It's all hit and trial until now, no real solution...

@as1ndu
Copy link

as1ndu commented Jun 29, 2020

My advice is to switch to https://appwrite.io/

@dhikshithrm
Copy link

It's all hit and trial until now, no real solution...

i've wasted so much of my time😥

@erluxman
Copy link
Author

yea me too

@alinabel
Copy link

alinabel commented Jul 19, 2020

any updates here ? i have same problem nothing of above works

edit: i search more and find sul down

@alinabel
Copy link

alinabel commented Jul 19, 2020

im find sulution work with me try goto android/setting.gradle on realy top add this tow liens

include ':library'
include ':app'

@Shivanshi1706
Copy link

It's all hit and trial until now, no real solution...

I have spent 3 days with 0 output

@naveen6768
Copy link

me too

@Salakar
Copy link
Member

Salakar commented Aug 25, 2020

Hey 👋

Our rework of the the FlutterFire plugins to depend on a shared 'core' (which controls the versions of the Firebase SDKs used on Android) as part of the FlutterFire roadmap was published over a week ago with a ton of fixes and new features.

Please could you try the new versions and see if this is still an issue? Additionally the documentation site now covers Android installation, https://firebase.flutter.dev

If this is still an issue then please submit a new up to date GitHub issue.

For help migrating to the new plugins please see the new migration guide: https://firebase.flutter.dev/docs/migration

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
impact: critical Usually a production crash with high user impact. (P1) impact: crowd Affects many people, though not necessarily a specific customer with an assigned label. (P2) platform: android Issues / PRs which are specifically for Android. platform: ios Issues / PRs which are specifically for iOS. type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests