Android SDK
- GitHub
- For Java based app: Android (Java)
The App Upgrade Android SDK helps you easily integrate with the App Upgrade service. The SDK communicates with App Upgrade and checks your app version against the version information configured in App Upgrade. Based on the response, it will:
- Show a non-dismissable update popup when the app requires a forced update. When the user taps it, the SDK opens the app store so the user can update.
- Show a dismissable update popup when the app should be updated but the update is not mandatory.
- Do nothing when no action is required.
Installation
- Install via gradle Add the JitPack repository to your settings.gradle file
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
...
maven { url "https://jitpack.io" }
}
}
If you are using gradle version prior to 7.x.x add the following in your root build.gradle.kts at the end of repositories:
allprojects {
repositories {
...
maven ("https://jitpack.io")
}
}
How to use?
Follow the Getting Started guide to create project and get the x-api-key.
Add the dependency to your project.
dependencies {
implementation 'com.github.appupgrade-dev:app-upgrade-android-sdk:1.0.3'
}
- Internet Permission required. Add the following in AndroidManifest.xml file if not already present.
<uses-permission android:name="android.permission.INTERNET" />
- If you are using
minifyEnabled trueit may obfuscate the code. Add the following rule in proguard-rules.pro to make sure SDK shows the popup.
# Keep all classes in the App Upgrade SDK package
-keep class com.appupgrade.app_upgrade_android_sdk.** { *; }
- Integrate with your app. Add the following code in your MainActivity.kt -> onCreate method.
class MainActivity : AppCompatActivity() {
private lateinit var appUpgrade: AppUpgrade
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// App Upgrade
val xApiKey = "ZWY0ZDhjYjgtYThmMC00NTg5LWI0NmUtMjM5OWZkNjkzMzQ5"
val appInfo = AppInfo(
appId = "com.android.com",
appName = "Wallpaper app",
appVersion = "1.0.0",
platform = "android",
environment = "production",
appLanguage = "es"
)
//Optional
val alertDialogConfig = AlertDialogConfig(
title = "Update Required", //Default: Please Update
updateButtonTitle = "Update Now", //Default: Update Now
laterButtonTitle = "Not Now" //Default: Later
)
val appUpgrade = AppUpgrade()
appUpgrade.checkForUpdates(this, xApiKey, appInfo, alertDialogConfig)
}
}
Note:
- For opening the Google Play Store the app should be live.
- It might not be able to open the Google Play Store in simulator. You can try it in physical device.
- You can find a sample Kotlin app from here app-upgrade-android-kotlin-demo-app
- Read detailed blog on how to integrate Kotlin app from here How to upgrade/force upgrade Android Kotlin app
Fields
- appId: App Id of your app. Know how to find appId for your app. (Required)
- appName: Your app name. (Required)
- appVersion: Version of your app. (Required)
- platform: This could be android or ios (Required)
- environment: This could be for example development, int, production (Required)
- appLanguage: This is your app language. Example: en, es etc. This will be used to localize the update message. (Optional)
Customizing the Alert popup
You can optionally pass the alertDialogConfig object to customize the alert popup.
- title: Main title shown to user.
- updateButtonTitle: Update button title shown to user.
- laterButtonTitle: Later button title shown to user.
Redirect user to store other than App Store or Google Play Store.
Supported Stores :
| Apple App Store | Google Play Store | Amazon Appstore | Huawei AppGallery | Other Android Markets |
|---|---|---|---|---|
| ✓ | ✓ | ✓ | ✓ | ✓ If your app marketplace is not one of these, you can pass your own store URL. |
If you want users to redirect to store other than App Store or Google Play Store. You can add these additional parameters preferredAndroidMarket.
- preferredAndroidMarket: PreferredAndroidMarket.AMAZON // or PreferredAndroidMarket.HUAWEI or PreferredAndroidMarket.OTHER If not provided default is Google Play Store. If the SDK cannot open the preferred marketplace because it is not available, the default Google Play Store listing will open.
- otherAndroidMarketUrl: 'https://someotherandroidmarket.com/app/id'// Required if preferredAndroidMarket is Other.
Example:
class MainActivity : AppCompatActivity() {
private lateinit var appUpgrade: AppUpgrade
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// App Upgrade
val xApiKey = "ZWY0ZDhjYjgtYThmMC00NTg5LWI0NmUtMjM5OWZkNjkzMzQ5"
val appInfo = AppInfo(
appId = "com.android.com",
appName = "Wallpaper app",
appVersion = "1.0.0",
platform = "android",
environment = "production",
appLanguage = "es",
preferredAndroidMarket = PreferredAndroidMarket.HUAWEI // or PreferredAndroidMarket.AMAZON or PreferredAndroidMarket.OTHER If not provided default is Google Play Store. Optional
otherAndroidMarketUrl = "https://otherandroidmarketurl.com/app/id" // Required if preferredAndroidMarket is OTHER.
)
val appUpgrade = AppUpgrade()
appUpgrade.checkForUpdates(this, xApiKey, appInfo)
}
}
Screenshot

Changelog
Please see CHANGELOG for more information what has changed recently.
Need help?
If you're looking for help, please write to us at support@appupgrade.dev
