Preparing Your Android Project

The first step towards integration is to prepare your Android Studio and its dependencies.

Android Studio projects contain two levels of build.gradle files: Project level build.gradle file and Module level build.gradle file. We need to make appropriate additions to dependencies at both levels as described below.

Making changes to Project Level build.gradle

Please update the following entry to your repositories under allProjects in Project Level build.gradle file.

buildscript{
    .
    .
    repositories {
        jcenter()
    }
    .
    .
    dependencies {
        .
        .
        classpath 'com.google.gms:google-services:4.3.15'
        .
        .
    }
    .
    .
}

allprojects {
    .
    . 
    repositories {
        jcenter()
        maven {
               url "http://android-lib.kruzr.co:8081/repository/kruzr-android-assistant/"
               allowInsecureProtocol true
        }
    }
    .   
    .
}

Making Changes to Module Level build.gradle

Please add the following dependency to your Module Level build.gradle file as shown below

dependencies {
      implementation 'co.kruzr.assistant:kruzrmodule:3.0.0.beta.2'
}

Adding lintOptions and CompileOptions to avoid unexpected issues

Specify lintOptions to prevent extraneous lint errors, specify packagingOptions to prevent unnecessary files from being included in your app (which may otherwise cause problems) and specify compileOptions to use Java 8 to allow your app to be installed on pre-Nougat devices.


android {

    lintOptions {
        disable 'InvalidPackage'
    }

    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }

   compileOptions {
      sourceCompatibility = 1.8
      targetCompatibility = 1.8
   }
}

Make Changes to Android Manifest

Please make sure that you make the following additions to your Android Manifest

<uses-permission android:name="android.permission.INTERNET" />

/**
*	usesCleartextTraffic is meant for Development environments only. 
*	In production environments and before uploading to PlayStore, please remove this tag 
*/

<application
   android:usesCleartextTraffic="true"
   ...
>

Following runtime permissions are added automatically by the SDK. These are mandatory permissions and you will need them before starting trip.

<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />

<!--     Permission for vehicle tracking-->
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />

Along with these we also have

<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

Once you have made changes to these dependencies and set-up the above options, you are ready to set-up Initializations of Kruzr SDK within your app. Please continue to the next section!

Last updated

Was this helpful?