3

I took back an old android project that hasn't been updated since more than 1 year and I tried to set it up with the current google librairies.

But I can't figure out how to solve one issue:

My application has 4 variants: devDebug, devRelease, prodDebug and prodRelease. Building the project is only working on *Debug ones. Release variants are producing this error:

Crashlytics could not find the resource file generated by Google Services. You may need to execute the :processGoogleServices Task.Please check your Firebase project configuration (https://firebase.google.com/docs/android/setup).

The application was already registred to firebase and the google-services.json file is already present (I also re-downloaded to be sure).

Some code inside the root gradle file:

dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'
        //apt : https://bitbucket.org/hvisser/android-apt
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
        classpath 'com.google.gms:google-services:4.3.4'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.4.1'
    }

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url 'https://jitpack.io'
        }
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
}

Some code of the app gradle file:

apply plugin: 'com.android.application'

android {

    compileOptions {
        coreLibraryDesugaringEnabled true
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    dexOptions {
        javaMaxHeapSize "4g"
    }

    signingConfigs {
        release_config {
            // config obfuscated
        }
    }
    compileSdkVersion 28
    buildToolsVersion '28.0.3'
    defaultConfig {
        applicationId "my.company.com"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 107
        versionName "1.19.0"

        vectorDrawables.useSupportLibrary = true
        multiDexEnabled true
    }
    
    dataBinding {
        enabled = true
    }
    
    // workaround for "duplicate files during packaging of APK" issue
    // see https://groups.google.com/d/msg/adt-dev/bl5Rc4Szpzg/wC8cylTWuIEJ
    packagingOptions {
        exclude 'META-INF/ASL2.0'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'

        //Workaround to an issue due to google play-services 11.0.0 + rxJava
        exclude 'META-INF/rxjava.properties'
    }

    lintOptions {
        // Inspired by https://stackoverflow.com/a/51363161/3520621
        checkReleaseBuilds false
        abortOnError false
    }

    configurations.all {
        resolutionStrategy {
            force 'com.google.android.gms:play-services-basement:17.0.0'
        }
    }

    buildTypes {
        //Release -> Production version.
        release {
            debuggable false
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release_config

        }
        //Debug -> Development version.
        debug {
            applicationIdSuffix ".debug"
            versionNameSuffix " - debug"
            debuggable true
        }
    }

    flavorDimensions "public"

    productFlavors {
        dev {
            applicationIdSuffix ".dev"
            versionNameSuffix " - dev"
            dimension "public"
        }

        prod {
            dimension "public"
        }

    }
}

ext {
    supportLibVersion = '28.0.0'
}

dependencies {
    implementation group: 'com.google.firebase', name: 'firebase-analytics', version: '17.3.0'
    implementation 'com.google.firebase:firebase-crashlytics:17.3.0'

    // other libraries...
}

apply plugin: 'com.google.firebase.crashlytics'

configurations {
    cleanedAnnotations
    compile.exclude group: 'org.jetbrains', module: 'annotations'
}

Any hints are welcome.

Thanks.

MHogge
  • 5,408
  • 15
  • 61
  • 104

1 Answers1

3

The error is literally telling you what to do.

In terminal run:

./gradlew :app:processProdReleaseGoogleServices

or

./gradlew :app:processDevReleaseGoogleServices
Rick Sanchez
  • 4,528
  • 2
  • 27
  • 53
  • I forgot to mention it but I tried those commands and what I get is `Task 'processDevReleaseGoogleServices' not found in project ':app'` – MHogge Nov 26 '20 at 21:15
  • 2
    Ok i Found out why I couldn't run the task... I was missing `apply plugin: 'com.google.gms.google-services'`. Thank you for your time. – MHogge Nov 26 '20 at 21:32
  • I've got that and have exactly same problem – Dani Aug 29 '21 at 22:48