Skip to content

hyperdevs-team/android-app-updates-helper

Repository files navigation

Android App Updates Helper

Release

This utility library aims to help Android developers to use the Google Play In-App Updates API in an easy way.

It's highly encouraged that you first read the Google Play In-App Updates API documentation before using this library in order to understand the core concepts of the library.

Setting Up

In your main build.gradle, add jitpack.io repository in the allprojects block:

Groovy
allprojects {
    repositories {
        maven { url "https://jitpack.io" }
    }
}
Kotlin
allprojects {
    repositories {
        maven(url = "https://jitpack.io")
    }
}

Add the following dependencies to your app or library's build.gradle:

Groovy
dependencies {
    implementation "com.github.hyperdevs-team:android-app-updates-helper:2.0.0"
}
Kotlin
dependencies {
    implementation("com.github.hyperdevs-team:android-app-updates-helper:2.0.0")
}

You'll also need to add support for Java 8 in your project. To do so:

Groovy
android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }
}
Kotlin
android {
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }
}

How to use

  • Create a new AppUpdatesHelper.
  • Start listening for app update changes with AppUpdatesHelper.startListening(), for example in Activity.onCreate() or in Fragment.onViewCreated().
  • Stop listening for app update changes with AppUpdatesHelper.stopListening() in Activity.onDestroy() or in Fragment.onDestroyView().
  • Request app update information with AppUpdatesHelper.getAppUpdateInfo().
  • Request a flexible or immediate update with AppUpdatesHelper.startFlexibleUpdate() or AppUpdatesHelper.startImmediateUpdate()

Check the example app for more implementation details about flexible and immediate updates.

You can also use a fake implementation to test in-app updates.

Keep in mind that you may not see in-app updates if these conditions don't match:

  • The package name of the app is exactly the one you'd like to test in-app updates with.
  • The app must be signed with the same keys that you used to sign the app you want to test in-app updates with.
  • If the app is not published yet or you want to test with internal app sharing or closed tracks, ensure that any of your Google accounts in your device has access to said app in Google Play Store.
  • Check if the Google Play Store displays updates for the app you want to use to test in-app updates.

Please ensure that all conditions apply when using this library in order to avoid unnecessary headaches.

Using the example app

In order to ease using the example app with the sample data of your own app, you can create an app_config.properties file in the root of the project with the following content:

applicationId=your.application.id
keystorePath=/full/path/to/your/keystore/file
keystorePwd=your_keystore_password
keystoreAlias=your_keystore_alias
keystoreAliasPwd=your_keystore_alias_password

These values will be picked up by the compilation process of the example app and will set the application ID and signing configurations for you.

Authors & Collaborators

Acknowledgements

The work in this repository up to April 28th, 2021 was done by bq. Thanks for all the work!!

License

This project is licensed under the Apache Software License, Version 2.0.

Copyright (C) 2021 HyperDevs

Copyright (C) 2019 BQ

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.