Background location sample project using LAN LiveLocation plugin.
- Android OS (Tested on Android 10 and Android 14 devices)
- iOS (Coming soon)
-
Install
External Dependency Manager for Unity
: -
Install
Live Location
using the Package Manager :- Open the Package Manager Window.
- Click the add button in the Package Manager's toolbar.
- Choose 'Add package from git url'.
- Copy and paste
https://github.com/krlan2789/Unity-LAN-LiveLocation-Plugin.git
into the textbox, then enter.
-
Make sure minimum API Level set to
API Level 26
: -
Check following build settings :
-
Add required-optional 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" /> <!-- Required permissions --> <!-- Optional permissions --> <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" /> <!-- Optional permissions --> <application> <activity android:name="com.unity3d.player.UnityPlayerActivity" android:theme="@style/UnityThemeSelector"> ...
-
Insert script below into
Assets\Plugins\Android\launcherTemplate.gradle
:... android { ... **PACKAGING_OPTIONS****PLAY_ASSET_PACKS****SPLITS** // Requirement for Live Location packagingOptions { pickFirst('META-INF/okio.kotlin_module') pickFirst('META-INF/kotlinx_coroutines_core.version') } // Requirement for Live Location **BUILT_APK_LOCATION** ... }
-
Insert script below into
Assets\Plugins\Android\mainTemplate.gradle
:... // Android Resolver Exclusions End android { ... **PACKAGING_OPTIONS** // Requirement for Live Location packagingOptions { pickFirst('META-INF/okio.kotlin_module') pickFirst('META-INF/kotlinx_coroutines_core.version') } // Requirement for Live Location } **IL_CPP_BUILD_SETUP** ...
-
Insert script below into
Assets\Plugins\Android\gradleTemplate.properties
:... android.enableJetifier=true # Android Resolver Properties End **ADDITIONAL_PROPERTIES** # Requirement for Live Location android.suppressUnsupportedCompileSdk=34 # Requirement for Live Location