react-native-background-geolocation: Gradle project sync failed

My environment

Plugin version:

    "react-native-background-fetch": "^2.6.1",
    "react-native-background-geolocation": "^3.0.9",

Platform: Android OS Version: 27 Device manufacturer / model: / React Native version:

    "react-native": "0.60.0",

Expected Behaviour

No gradle project sync issues

Actual Behaviour

Gradle project sync failed

Steps to Reproduce

  1. Install react-native-background-geolocation according to the documentation for Android
  2. Gradle project sync failed message on Android Studio IDE => click Try Again

Debug logs

Logs
WARNING: API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
REASON: Called from: /Users/laurens/Documents/SweetMustard/locator/android/app/build.gradle:209
WARNING: Debugging obsolete API calls can take time during configuration. It's recommended to not keep it on at all times.
Affected Modules: app

Issue

The issue seems to come from following code in app build.gradle

// [Added by react-native-background-geolocation] Purge debug sounds from release build.
def purgeBackgroundGeolocationDebugResources(applicationVariants) {
    if ((rootProject.ext.has("removeBackgroundGeolocationDebugSoundsInRelease")) && (rootProject.ext.removeBackgroundGeolocationDebugSoundsInRelease == false)) return
    applicationVariants.all { variant ->
        if (variant.buildType.name == "release") {
            println("[react-native-background-geolocation] Purging debug resources in release build")
            variant.**mergeResources**.doLast {
                delete(fileTree(dir: variant.mergeResources.outputDir, includes: ["raw_tslocationmanager*"]))
            }
        }
    }
}

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 15 (13 by maintainers)

Most upvoted comments

I was able to clear the warning by following @mikehardy link. Final code:

def purgeBackgroundGeolocationDebugResources(applicationVariants) {
    if ((rootProject.ext.has("removeBackgroundGeolocationDebugSoundsInRelease")) && (rootProject.ext.removeBackgroundGeolocationDebugSoundsInRelease == false)) return
    applicationVariants.all { variant ->
        if (variant.buildType.name == "release") {
            println("[react-native-background-geolocation] Purging debug resources in release build")
            variant.mergeResourcesProvider.configure {
                doLast {
                    delete(fileTree(dir: outputDir, includes: ["raw_tslocationmanager*"]))
                }
            }
        }
    }
}

That’s where this warning was coming from! I was going to hunt that down at some point, forgot about this code.

I agree it’s not time-pressing, but perhaps seeing the diff on similar code is useful as it seems to snipe this one (module change from assets to resources) https://stackoverflow.com/posts/39760001/revisions

This is fixed in 3.2.0. See new Setup Guides

I’m probably the only person who actually uses removeBackgroundGeolocationDebugSoundsInRelease = false. When I publish the SampleApp to Play Store, I actually want the debug sounds to stay.