|
3 | 3 |
|
4 | 4 | This utility library aims to help Android developers to use the [Google Play In-App Updates API](https://developer.android.com/guide/app-bundle/in-app-updates) in an easy way. |
5 | 5 |
|
6 | | -**It's highly encouraged that you first read the [Google Play In-App Updates API](https://developer.android.com/guide/app-bundle/in-app-updates) documentation before using this library in order to understand the core concepts of the library.** |
| 6 | +> It's highly encouraged that you first read the [Google Play In-App Updates API](https://developer.android.com/guide/app-bundle/in-app-updates) documentation before using this library in order to understand the core concepts of the library. |
| 7 | +
|
| 8 | +## Setting Up |
| 9 | +In your main `build.gradle`, add [jitpack.io](https://jitpack.io/) repository in the `allprojects` block: |
| 10 | + |
| 11 | +<details open><summary>Groovy</summary> |
7 | 12 |
|
8 | | -## Installation |
9 | | -Add the following dependencies to your main `build.gradle`: |
10 | 13 | ```groovy |
11 | 14 | allprojects { |
12 | 15 | repositories { |
13 | 16 | maven { url "https://jitpack.io" } |
14 | 17 | } |
15 | 18 | } |
16 | 19 | ``` |
| 20 | +</details> |
17 | 21 |
|
18 | | -Add the following dependencies to your app's `build.gradle`: |
| 22 | +<details><summary>Kotlin</summary> |
19 | 23 |
|
20 | | -* For Gradle < 4.0 |
21 | | - ```groovy |
22 | | - dependencies { |
23 | | - compile "com.github.bq:android-app-updates-helper:1.0.2" |
| 24 | +```kotlin |
| 25 | +allprojects { |
| 26 | + repositories { |
| 27 | + maven(url = "https://jitpack.io") |
24 | 28 | } |
25 | | - ``` |
| 29 | +} |
| 30 | +``` |
| 31 | +</details> |
| 32 | + |
| 33 | + |
| 34 | +Add the following dependencies to your app or library's `build.gradle`: |
| 35 | + |
| 36 | +<details open><summary>Groovy</summary> |
| 37 | + |
| 38 | +```groovy |
| 39 | +dependencies { |
| 40 | + implementation "com.github.bq:android-app-updates-helper:1.0.2" |
| 41 | +} |
| 42 | +``` |
| 43 | +</details> |
| 44 | + |
| 45 | + |
| 46 | +<details><summary>Kotlin</summary> |
| 47 | + |
| 48 | +```kotlin |
| 49 | +dependencies { |
| 50 | + implementation("com.github.bq:android-app-updates-helper:1.0.2") |
| 51 | +} |
| 52 | +``` |
| 53 | +</details> |
26 | 54 |
|
27 | | -* For Gradle 4.0+ |
28 | | - ```groovy |
29 | | - dependencies { |
30 | | - implementation "com.github.bq:android-app-updates-helper:1.0.2" |
| 55 | +You'll also need to add support for Java 8 in your project. To do so: |
| 56 | +<details open><summary>Groovy</summary> |
| 57 | + |
| 58 | +```groovy |
| 59 | +android { |
| 60 | + compileOptions { |
| 61 | + sourceCompatibility JavaVersion.VERSION_1_8 |
| 62 | + targetCompatibility JavaVersion.VERSION_1_8 |
| 63 | + } |
| 64 | + kotlinOptions { |
| 65 | + jvmTarget = "1.8" |
31 | 66 | } |
32 | | - ``` |
| 67 | +} |
| 68 | +``` |
| 69 | +</details> |
33 | 70 |
|
34 | | -## Example usage |
| 71 | +<details><summary>Kotlin</summary> |
| 72 | + |
| 73 | +```kotlin |
| 74 | +android { |
| 75 | + compileOptions { |
| 76 | + sourceCompatibility = JavaVersion.VERSION_1_8 |
| 77 | + targetCompatibility = JavaVersion.VERSION_1_8 |
| 78 | + } |
| 79 | + kotlinOptions { |
| 80 | + jvmTarget = "1.8" |
| 81 | + } |
| 82 | +} |
| 83 | +``` |
| 84 | +</details> |
| 85 | + |
| 86 | +## How to use |
35 | 87 | * Create a new _AppUpdatesHelper_. |
36 | | -* Start listening for app update changes with _AppUpdatesHelper.startListening()_, for example in _onCreate()_. |
37 | | -* Stop listening for app update changes with _AppUpdatesHelper.stopListening()_ in _onDestroy()_. |
| 88 | +* Start listening for app update changes with _AppUpdatesHelper.startListening()_, for example in _Activity.onCreate()_ or in _Fragment.onViewCreated()_. |
| 89 | +* Stop listening for app update changes with _AppUpdatesHelper.stopListening()_ in _Activity.onDestroy()_ or in _Fragment.onDestroyView()_. |
38 | 90 | * Request app update information with _AppUpdatesHelper.getAppUpdateInfo()_. |
39 | 91 | * Request a flexible or immediate update with _AppUpdatesHelper.startFlexibleUpdate()_ or _AppUpdatesHelper.startImmediateUpdate()_ |
40 | 92 |
|
41 | 93 | Check the [example app](app) for more implementation details about [flexible](app/src/main/kotlin/com/bq/appupdateshelper/flexible/FlexibleUpdateActivity.kt) |
42 | 94 | and [immediate](app/src/main/kotlin/com/bq/appupdateshelper/immediate/ImmediateUpdateActivity.kt) updates. |
43 | 95 |
|
44 | | -If you use the example app, don't forget the following things when testing: |
45 | | -* Change the package name of the example app to the one you'd like to test in-app updates with. |
46 | | -* Sign the example app with the same keys that you used to sign the app you want to test in-app updates with. |
47 | | -* 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. |
48 | | -
|
49 | 96 | You can also use a [fake implementation](app/src/main/kotlin/com/bq/appupdateshelper/fake/FakeUpdateActivity.kt) to test in-app updates. |
50 | 97 |
|
| 98 | +Keep in mind that you may not see in-app updates if these conditions don't match: |
| 99 | +* The package name of the app is **exactly** the one you'd like to test in-app updates with. |
| 100 | +* The app must be signed with the same keys that you used to sign the app you want to test in-app updates with. |
| 101 | +* If the app is not published yet or you want to test with internal app sharing or closed tracks, |
| 102 | +ensure that any of your Google accounts in your device has access to said app in Google Play Store. |
| 103 | +* Check if the Google Play Store displays updates for the app you want to use to test in-app updates. |
| 104 | + |
| 105 | +Please ensure that all conditions apply when using this library in order to avoid unnecessary headaches. |
| 106 | + |
| 107 | +### Using the example app |
| 108 | +In order to ease using the example app with the sample data of your own app, |
| 109 | +you can create an `app_config.properties` file in the root of the project with the following content: |
| 110 | +```properties |
| 111 | +applicationId=your.application.id |
| 112 | +keystorePath=/full/path/to/your/keystore/file |
| 113 | +keystorePwd=your_keystore_password |
| 114 | +keystoreAlias=your_keystore_alias |
| 115 | +keystoreAliasPwd=your_keystore_alias_password |
| 116 | +``` |
| 117 | + |
| 118 | +These values will be picked up by the compilation process of the example app |
| 119 | +and will set the application ID and signing configurations for you. |
| 120 | + |
51 | 121 | ## Authors & Collaborators |
52 | | -* [Adrián García](https://github.com/adriangl) - Author and maintainer |
53 | | -* [Daniel Sánchez Ceinos](https://github.com/danielceinos) - Contributor |
| 122 | +* **[Adrián García](https://github.com/adriangl)** - *Author and maintainer* |
| 123 | +* **[Daniel Sánchez Ceinos](https://github.com/danielceinos)** - *Contributor* |
54 | 124 |
|
55 | 125 | ## License |
| 126 | +This project is licensed under the Apache Software License, Version 2.0. |
56 | 127 | ``` |
57 | 128 | Copyright (C) 2019 BQ |
58 | 129 |
|
|
0 commit comments