Skip to content

Latest commit

 

History

History
123 lines (95 loc) · 3.47 KB

INSTALL-ANDROID.md

File metadata and controls

123 lines (95 loc) · 3.47 KB

Android Installation

You will have to install the plugin by manually downloading a Release from this repository. The plugin is not currently submitted to a package manager (eg: jCenter)

Create a folder in the root of your application project, eg: /Libraries and place the extracted background-geolocation folder into it:

eg: 📂 Libraries/background-geolocation-lt

Gradle Configuration

📂 settings.gradle

+include ':background-geolocation'
+project(':background-geolocation').projectDir = new File(rootProject.projectDir, './Libraries/background-geolocation-lt/android/background-geolocation')

📂 android/build.gradle

buildscript {
    ext {
        buildToolsVersion = "28.0.3"  // <-- set as desired
        compileSdkVersion = 28        // <-- set as desired
        targetSdkVersion = 28         // <-- set as desired
        minSdkVersion = 19            // <-- set as desired
+       appCompatVersion = "1.0.2"    // <-- AndroidX compatibility.  For pre-androidX, specify `com.android.support` version.
+       googlePlayServicesLocationVersion = "17.0.0"
    }
    ...
}

📂 app/build.gradle

android {
+    compileSdkVersion rootProject.ext.compileSdkVersion
     defaultConfig {
+        targetSdkVersion rootProject.ext.targetSdkVersion
         .
         .
         .
     }
     .
     .
     .
}

// Get a reference to background-geolocation project.
+Project background_geolocation = project(':background-geolocation')

// Apply background-geolocation's custom app.gradle file
+apply from: "${background_geolocation.projectDir}/app.gradle"

dependencies {
     .
     .
     .
+    implementation background_geolocation
}

You can now import and use the SDK in your application. See the Example.

AndroidManifest.xml

📂 android/app/src/main/AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.transistorsoft.backgroundgeolocation.react">

  <application
    android:name=".MainApplication"
    android:allowBackup="true"
    android:label="@string/app_name"
    android:icon="@mipmap/ic_launcher"
    android:theme="@style/AppTheme">

    <!-- react-native-background-geolocation licence -->
+   <meta-data android:name="com.transistorsoft.locationmanager.license" android:value="YOUR_LICENCE_KEY_HERE" />
    .
    .
    .
  </application>
</manifest>

ℹ️ Purchase a License

Proguard Config

📂 android/app/proguard-rules.pro

# BackgroundGeolocation lib tslocationmanager.aar is *already* proguarded
-keep class com.transistorsoft.** { *; }
-dontwarn com.transistorsoft.**

# BackgroundGeolocation (EventBus)
-keepclassmembers class * extends de.greenrobot.event.util.ThrowableFailureEvent {
    <init>(java.lang.Throwable);
}
-keepattributes *Annotation*
-keepclassmembers class ** {
    @org.greenrobot.eventbus.Subscribe <methods>;
}
-keep enum org.greenrobot.eventbus.ThreadMode { *; }
-keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent {
    <init>(java.lang.Throwable);
}

# logback
-keep class ch.qos.** { *; }
-keep class org.slf4j.** { *; }
-dontwarn ch.qos.logback.core.net.*

# OkHttp3
-dontwarn okio.**