skip to Main Content

Im trying to create a new flutter project with firebase I’ve got it to work on iOS but not android. I cant find the problem, the app builds correctly but it doesn’t seem like its connected to firebase.

this is my project level gradle file

buildscript {
    ext.kotlin_version = '1.9.22'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.3.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.4.1'
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

plugins {
    id "com.android.application"
    id "kotlin-android"
    id "dev.flutter.flutter-gradle-plugin"
    id "com.google.gms.google-services"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

android {
    namespace "com.whysApp.whyAppen"
    compileSdkVersion flutter.compileSdkVersion
    ndkVersion "25.1.8937393"

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    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.whysApp.whyAppen"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdkVersion 21
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation 'com.google.firebase:firebase-analytics'
    implementation platform('com.google.firebase:firebase-bom:32.7.2')
}

and this is the app level

I have tried searching for solutions but the app level gradle file looks different from mine. Im not really sure where the problem lies

2

Answers


  1. I prefer to use Firebase tools, it allows you to easily integrate Firebase for all platforms.
    First, use this command to install Firebase tools.

    npm install -g firebase-tools

    then use

    firebase login

    To log in to your Firebase console. then:

    firebase init

    use this command to do all setting it will ask you to choose platforms i.e ios android e.t.c

    and then it ask you to select firebase project then after finishing process it will automatically connect firebase in android and ios.

    Login or Signup to reply.
  2. Use Firebase tools, it allows you to easily integrate Firebase for all platforms. First, use this command to install Firebase tools.
    for this refer [https://firebase.google.com/docs/cli][1]

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search