This guide walks you through setting up background location functionality in Unity using the LAN LiveLocation plugin. Follow the steps below to ensure a smooth integration.
- Android OS: Tested on Android 10 and Android 14 devices.
- iOS: Coming soon.
To manage dependencies, you need to install the External Dependency Manager for Unity:
- Follow the manual installation guide.
- Alternatively, download and import the latest custom package.
Add the Live Location plugin to your Unity project:
- Open the Package Manager window.
- Click the Add button in the toolbar.
- Select Add package from git URL.
- Paste the following URL:
https://github.com/krlan2789/Unity-LAN-LiveLocation-Plugin.git.
Ensure the minimum API level is set to API Level 26.
Check and configure the required build settings.
Add the following permissions to Assets/Plugins/Android/AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.LAN.BackgroundLocation" xmlns:tools="http://schemas.android.com/tools">
<!-- Required permissions -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" android:minSdkVersion="29" />
<!-- Optional permissions -->
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<application>
<activity android:name="com.unity3d.player.UnityPlayerActivity" android:theme="@style/UnityThemeSelector">
...
</application>
</manifest>Insert the following script into Assets\Plugins\Android\launcherTemplate.gradle:
android {
...
packagingOptions {
pickFirst('META-INF/okio.kotlin_module')
pickFirst('META-INF/kotlinx_coroutines_core.version')
}
}Insert the following script into Assets\Plugins\Android\mainTemplate.gradle:
android {
...
packagingOptions {
pickFirst('META-INF/okio.kotlin_module')
pickFirst('META-INF/kotlinx_coroutines_core.version')
}
}Insert the following script into Assets\Plugins\Android\gradleTemplate.properties:
android.enableJetifier=true
android.suppressUnsupportedCompileSdk=34By following these steps, you can successfully integrate background location functionality into your Unity project using the LAN LiveLocation plugin






