Skip to content

Flutter and Firebase Integration for Android does not work #41686

@allenind

Description

@allenind

Hello, I need to integrate firebase so I can use the RDS, and other functions for the application I am developing, however once you edit the "project_name/android/app/build.gradle/" you will not be able to run the flutter application again. I am stuck at this problem. I tried adding firebase to both old flutter project files, and to new ones (from create flutter project in android studio).

Steps to Reproduce

1.) Create new flutter project using android studio, create your own package name.
2.) Go to Firebase Console, either create a new project or use one already created before.
3.) Go through the set-up to register your app
4.) Add firebase SDK to your app: changing the app/build.gradle to include this "implementation 'com.google.firebase:firebase-analytics:17.2.0'" and "apply plugin: 'com.google.gms.google-services'"

Logs

* Error running Gradle:
ProcessException: Process "C:\Users\User\Documents\diabeates_mobile\diabeates_mobile\diabeates_mobile\flutter_diabeates\android\gradlew.bat" exited abnormally:

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\User\Documents\diabeates_mobile\diabeates_mobile\diabeates_mobile\flutter_diabeates\android\app\build.gradle' line: 24

* What went wrong:
A problem occurred evaluating project ':app'.
> ASCII

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

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

BUILD FAILED in 0s
  Command: C:\Users\User\Documents\diabeates_mobile\diabeates_mobile\diabeates_mobile\flutter_diabeates\android\gradlew.bat app:properties

Please review your Gradle project setup in the android/ folder.

Edits:

[√] Flutter (Channel beta, v1.9.1+hotfix.2, on Microsoft Windows [Version 10.0.18362.356], locale en-PH)
    • Flutter version 1.9.1+hotfix.2 at C:\flutter
    • Framework revision 2d2a1ffec9 (3 weeks ago), 2019-09-06 18:39:49 -0700
    • Engine revision b863200c37
    • Dart version 2.5.0


[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at C:\Users\User\AppData\Local\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
    • All Android licenses accepted.

[√] Android Studio (version 3.5)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 39.0.3
    • Dart plugin version 191.8423
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)

[√] VS Code (version 1.38.1)
    • VS Code at C:\Users\User\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.4.1

[√] Connected device (1 available)
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)

Heres my 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 28

    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 "indefenzobuendia.flutter_diabeates"
        minSdkVersion 16
        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 {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.google.firebase:firebase-analytics:17.2.0'
    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'
}

// Add to the bottom of the file
apply plugin: 'com.google.gms.google-services'

Metadata

Metadata

Assignees

No one assigned

    Labels

    p: firebaseFirebase pluginspackageflutter/packages repository. See also p: labels.t: gradle"flutter build" and "flutter run" on AndroidtoolAffects the "flutter" command-line tool. See also t: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions