Android Installation
January 20, 2026 ยท View on GitHub
:open_file_folder: android/build.gradle (or build.gradle.kts)
Note
At the root of your /android folder, your Flutter app will contain one of the following files:
build.gradlebuild.gradle.kts(new Kotlin-based version)
build.gradle
If your app contains an android/build.gradle, you can control the version of Google's play-services:location that this plugin will use:
+ext {
+ playServicesLocationVersion = "21.3.0" // or higher / as desired
+}
build.gradle.kts
OR if your app contains an android/build.gradle.kts:
allprojects {
+ ext {
+ set("playServicesLocationVersion", "21.3.0") // or higher / as desired
+ }
}
:open_file_folder: android/app/build.gradle (or build.gradle.kts)
build.gradle
If your app contains an android/app/build.gradle:
// flutter_background_geolocation
+Project background_geolocation = project(':flutter_background_geolocation')
+apply from: "${background_geolocation.projectDir}/background_geolocation.gradle"
android {
.
.
.
buildTypes {
release {
.
.
.
minifyEnabled true
+ shrinkResources false // <-- REQUIRED !!!
}
}
}
build.gradle.kts
OR if your app contains an android/app/build.gradle.kts:
+val backgroundGeolocation = project(":flutter_background_geolocation")
+apply { from("${backgroundGeolocation.projectDir}/background_geolocation.gradle") }
android {
.
.
.
buildTypes {
release {
.
.
.
isMinifyEnabled = true
+ isShrinkResources = false // <-- REQUIRED !!!
}
}
}
Configure your license
If you've not yet purchased a license to unlock Android, you can purchase one here. Otherwise, ignore this step (Android is fully functional in DEBUG builds without a license key so you can evaluate the plugin).
-
Login to Customer Dashboard to generate an application key:
-
Add your license-key to
android/app/src/main/AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.your.package.id">
<application>
<!-- flutter_background_geolocation licence -->
+ <meta-data android:name="com.transistorsoft.locationmanager.license" android:value="YOUR_LICENCE_KEY_HERE" />
.
.
.
</application>
</manifest>
v5 Licensing.
Version 5.0.0 of flutter_background_geolocation requires a new license-key format (previous license are no longer accepted). You can generate your new license in the customer dashboard.
These new license keys now have the ability to unlock any purshased add-on, without the need to add a separate license key for each:
- Polygon Geofencing
- Huawei HMS Adapter
- Firebase Adapter
Legacy License Keys
For versions of flutter_background_geolocation <v5.0.0:
Polygon Geofencing Add-on
If you've purchased a license for the Polygon Geofencing add-on, login to the customer dashboard and ensure you enable the [x] Polygon Geofencing entitlement to your license key. Update your Background Geolocation license with the new key (as documented above).
Android Headless Mode with enableHeadless: true
If you intend to respond to the BackgroundGeolocation SDK's events with your own dart callback while your app is terminated, that is Headless, See Android Headless Mode and perform those additional steps now.
BackgroundGeolocation.ready(Config(
enableHeadless: true // <--
));
background_fetch
Transistor Software manages a helpful free plugin you can optionally add to your app named background_fetch.
Tip
background_fetch is helpful for executing a periodic task (eg: every 15 minutes). You could use background_fetch to periodically request the current location:
// Execute a task about every 15 minutes:
BackgroundFetch.configure(BackgroundFetchConfig(
minimumFetchInterval: 15
), (String taskId) async { // <-- This is your periodic-task callback
var location = await BackgroundGeolocation.getCurrentPosition(
samples: 3,
extras: { // <-- your own arbitrary meta-data
"event": "getCurrentPosition"
}
);
print('[getCurrentPosition] $location');
BackgroundFetch.finish(taskId); // <-- signal that your task is complete
})