Requirements
This guide assumes you are targeting Android SDK 21 or above and that you have a valid nudge API key. If you do not yet have a nudge API key, please contact support@larky.com.
Before getting started, please make sure you are following these minimum requirements:
- Gradle: version 8.0
- Android plugin for Gradle: version 8.6.0
- Android Studio: version 2025.1.1
- Android compileSdkVersion: 36
- Android minSdkVersion: 21+
- Google services: 4.3.13
- In gradle.properties:
- android.useAndroidX=true
- android.enableJetifier=true
Importing the Library
Nudge is distributed through Maven.
Adding maven to your project-wide settings.gradle.kts file
This should be near imports like google. It is recommended to re-sync your project after making build.gradle changes to ensure dependencies are working and up to date
allprojects {
repositories {
google()
// Add the code starting here
maven {
url 'https://maven.nudge.larky.cloud'
}
// And ending here!
}
}Adding the nudge library as a dependency to your app-specific build.gradle file
Replace <LIB_VERSION_NUMBER> with the appropriate library version (found here).
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
testImplementation 'junit:junit:4.12'
// Add this line for Nudge
implementation 'releases.com.larky:nudge:<LIB_VERSION_NUMBER>'
}Adding the library to your project
Now that you've got the nudge library imported, we just need to add it into your app's functionality!
Add permissions to your AndroidManifest.xml (location-aware implementation only)
If you are using the location-aware implementation, add these lines of code to the AndroidManifest.xml file of your app if you are not using them already.
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
These are used to declare the permissions needed for nudge to access location services on the device. Without these in place, Android will throw a SecurityException when trying to utilize location.
NOTE: The nudge library only uses Fine Location but as of Android 12 (API 31), if you request Fine Location permissions you also need to declare Coarse Location in your manifest file.
Comments
0 comments
Article is closed for comments.