Skip to content

Latest commit

 

History

History
125 lines (88 loc) · 4.28 KB

README.md

File metadata and controls

125 lines (88 loc) · 4.28 KB

Unity Background Location

Background location sample project using LAN LiveLocation plugin.

Supported Platform

  • Android OS (Tested on Android 10 and Android 14 devices)
  • iOS (Coming soon)

Requirements and Installation

  1. Install External Dependency Manager for Unity :

    • Follows this step.
    • Or, download and import this custom package.
  2. 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.
  3. Make sure minimum API Level set to API Level 26 :

  4. Check following build settings :

  5. 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">
    ...
  6. 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**
        ...
    }
  7. 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**
    ...
  8. 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

Error When Some Build Settings Do Not Match

  1. Custom Gradle Properties Template :

  2. Custom Launcher Gradle and Custom Main Gradle :