Trouble with Firebase Setup in App and Server

Hamza6 months ago

Hey everyone,

I'm encountering an issue with Firebase setup in my app and server, and I'm hoping to get some guidance here.

I've integrated Firebase into both my app and server, but for some reason, it's not functioning as expected. The frustrating part is that I'm not receiving any error messages, making it difficult to pinpoint the problem. Strangely, the Firebase setup worked perfectly in an older version of my app, but now that I'm using Traccar Manager to build the app, I'm running into this issue.

If anyone has encountered a similar problem or has any insights into troubleshooting Firebase integration without explicit error messages, I would greatly appreciate your help. Thanks in advance for any assistance you can offer!

Dependencies set up correctly

Server Firebase setup

Anton Tananaev6 months ago

Have you built the right flavor of the app?

Hamza6 months ago

Yes..!

plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'com.google.gms.google-services'
    id 'com.google.firebase.crashlytics'
}

android {
    compileSdk 34
    defaultConfig {
        applicationId 'online.gpsnusantara.track'
        minSdkVersion 21
        targetSdkVersion 34
        versionCode 37
        versionName '4.1'
        multiDexEnabled true
    }
    namespace 'online.gpsnusantara.track'

    flavorDimensions 'version'
    productFlavors {
        regular {
            dimension 'version'
            ext.enableCrashlytics = false
        }
        google {
            dimension 'version'
            ext.enableCrashlytics = true
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        debug {
            applicationIdSuffix ".debug"
            versionNameSuffix "-debug"
        }
    }

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_17.toString()
    }
}

dependencies {
    implementation 'com.google.android.material:material:1.12.0'
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0'
    implementation 'androidx.preference:preference-ktx:1.2.1'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0'
    implementation 'androidx.core:core-ktx:1.13.1'
    implementation 'androidx.biometric:biometric-ktx:1.2.0-alpha05'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

    // Use the Firebase BoM to manage versions
    implementation platform('com.google.firebase:firebase-bom:33.0.0')

    // Add dependencies for the google flavor
    googleImplementation 'com.google.firebase:firebase-core'
    googleImplementation 'com.google.firebase:firebase-analytics'
    googleImplementation 'com.google.firebase:firebase-crashlytics'
    googleImplementation 'com.google.firebase:firebase-messaging'

    // Ensure the correct version for firebase-messaging
    implementation 'com.google.firebase:firebase-messaging:24.0.0'
}

tasks.register('copyFirebaseConfig', Copy) {
    from '../../environment/google-services'
    into '.'
    include 'traccar-manager-android.json'
    rename('traccar-manager-android.json', 'google-services.json')
}

afterEvaluate {
    tasks.matching { it.name.contains('Google') }.configureEach { task ->
        if (task.name.contains('Regular')) {
            task.enabled = false
        } else {
            task.dependsOn copyFirebaseConfig
        }
    }
}
Anton Tananaev6 months ago

Yes which?

Hamza6 months ago

Regular release

Anton Tananaev6 months ago

Then it's obviously not the right flavor.

Hamza6 months ago

So which one I needed to use ...!

Anton Tananaev6 months ago

The other one.

Hamza6 months ago

I added the google-services.json file to the app and changed the package name. Can you please guide me on what I need to do next?

Hamza6 months ago

Google Release ?

Anton Tananaev6 months ago

You have to build the Google flavor, of course. Because push notifications is a part of Google services.

Hamza6 months ago

ok Thanks :)