Skip to content

Commit 01c42bb

Browse files
Merge pull request #7 from approov/feature/update-service-layer-versions
Update approov-service-httpsurlconn to 3.5.4 and the Shapes app build
2 parents 3f87394 + 5408086 commit 01c42bb

7 files changed

Lines changed: 48 additions & 11 deletions

File tree

‎README.md‎

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,33 @@ The Approov integration is available via [`maven`](https://mvnrepository.com/rep
1111
The `Maven` repository is already present in the gradle.build file so the only import you need to make is the actual service layer itself:
1212

1313
```
14-
implementation("io.approov:service.httpsurlconn:3.5.3")
14+
implementation("io.approov:service.httpsurlconn:3.5.4")
15+
```
16+
17+
The service layer requires [core library desugaring](https://developer.android.com/studio/write/java8-support#library-desugaring) and a minimum SDK version of 23. Add the following to the app-level `build.gradle` file:
18+
19+
```
20+
android {
21+
defaultConfig {
22+
minSdkVersion 23
23+
}
24+
compileOptions {
25+
coreLibraryDesugaringEnabled true
26+
}
27+
}
28+
29+
dependencies {
30+
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.4'
31+
}
32+
```
33+
34+
Use Android Gradle plugin 8.x or later. With Android Gradle plugin 7.x, the build fails in D8 with a `NullPointerException` while it processes the service layer. With Android Gradle plugin 8.x and no desugaring, the build fails with `Dependency 'io.approov:service.httpsurlconn:3.5.4' requires core library desugaring to be enabled`.
35+
36+
If your release build uses R8 (`minifyEnabled true`), add these rules to your ProGuard rules file. The Approov SDK refers to optional Google Play services and Play Integrity classes, and Android Gradle plugin 8 stops the build with `Missing class` errors if they are not present:
37+
38+
```
39+
-dontwarn com.google.android.gms.tasks.**
40+
-dontwarn com.google.android.play.core.integrity.**
1541
```
1642

1743
Make sure you do a Gradle sync (by selecting `Sync Now` in the banner at the top of the modified `.gradle` file) after making these changes.
@@ -26,7 +52,7 @@ The following app permissions need to be available in the manifest to use Approo
2652
<uses-permission android:name="android.permission.INTERNET" />
2753
```
2854

29-
Note that the minimum SDK version you can use with the Approov package is 21 (Android 5.0).
55+
Note that the minimum SDK version you can use with the Approov package is 23 (Android 6.0).
3056

3157
Please [read this](https://approov.io/docs/latest/approov-usage-documentation/#targeting-android-11-and-above) section of the reference documentation if targeting Android 11 (API level 30) or above.
3258

‎SHAPES-EXAMPLE.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This quickstart is written specifically for native Android apps that are written
55
## WHAT YOU WILL NEED
66
* Access to a trial or paid Approov account
77
* The `approov` command line tool [installed](https://approov.io/docs/latest/approov-installation/) with access to your account
8-
* [Android Studio](https://developer.android.com/studio) installed (Android Studio Bumblebee 2021.1.1 is used in this guide)
8+
* [Android Studio](https://developer.android.com/studio) installed, in a version that supports Android Gradle plugin 8.9 (see the [compatibility table](https://developer.android.com/build/releases/gradle-plugin#android_gradle_plugin_and_android_studio_compatibility)). The Shapes app uses Android Gradle plugin 8.9.0 and Gradle 8.11.1, which require JDK 17.
99
* The contents of this repo
1010

1111
## RUNNING THE SHAPES APP WITHOUT APPROOV
@@ -45,9 +45,11 @@ The `approov-service-httpsurlconn` dependency needs to be added as follows to th
4545
![App Build Gradle](readme-images/app-gradle.png)
4646

4747
```
48-
implementation("io.approov:service.httpsurlconn:3.5.3")
48+
implementation("io.approov:service.httpsurlconn:3.5.4")
4949
```
5050

51+
The service layer requires [core library desugaring](https://developer.android.com/studio/write/java8-support#library-desugaring) and a minimum SDK version of 23. The Shapes app already sets `minSdkVersion 23`, `coreLibraryDesugaringEnabled true` and the `coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.4'` dependency in `app/build.gradle`, so no other change is necessary. If you add Approov to your own app, see [ADDING APPROOV SERVICE DEPENDENCY](README.md#adding-approov-service-dependency).
52+
5153
Make sure you do a Gradle sync (by selecting `Sync Now` in the banner at the top of the modified `.gradle` file) after making these changes.
5254

5355
Note that `approov-service-httpsurlconn` is actually an open source wrapper layer that allows you to easily use Approov with `HttpsUrlConnection`. This has a further dependency to the closed source Approov SDK itself.

‎shapes-app/app/build.gradle‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 31
4+
namespace "io.approov.shapes"
5+
compileSdkVersion 35
56
defaultConfig {
67
applicationId "io.approov.shapes"
7-
minSdkVersion 21
8-
targetSdkVersion 31
8+
minSdkVersion 23
9+
targetSdkVersion 34
910
versionCode 3
1011
versionName "3.0"
1112
}
@@ -27,11 +28,14 @@ android {
2728
compileOptions {
2829
sourceCompatibility JavaVersion.VERSION_1_8
2930
targetCompatibility JavaVersion.VERSION_1_8
31+
// Required by io.approov:service.httpsurlconn 3.5.4 and later
32+
coreLibraryDesugaringEnabled true
3033
}
3134
}
3235
}
3336

3437
dependencies {
38+
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.4'
3539
implementation fileTree(dir: 'libs', include: ['*.jar'])
3640
implementation 'androidx.appcompat:appcompat:1.4.1'
3741
}

‎shapes-app/app/proguard-rules.pro‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,9 @@
1616
# public *;
1717
#}
1818
-keep class com.criticalblue.approovsdk.** {*;}
19+
20+
# The Approov SDK refers to optional Google Play services and Play Integrity classes that
21+
# are not present unless the app includes those libraries. Android Gradle plugin 8 treats
22+
# missing classes as an error in R8.
23+
-dontwarn com.google.android.gms.tasks.**
24+
-dontwarn com.google.android.play.core.integrity.**

‎shapes-app/app/src/main/AndroidManifest.xml‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="io.approov.shapes">
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
43

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

‎shapes-app/build.gradle‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ buildscript {
88
mavenCentral()
99
}
1010
dependencies {
11-
classpath 'com.android.tools.build:gradle:7.1.1'
11+
classpath 'com.android.tools.build:gradle:8.9.0'
1212
// NOTE: Do not place your application dependencies here; they belong
1313
// in the individual module build.gradle files
1414
}

‎shapes-app/gradle/wrapper/gradle-wrapper.properties‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip

0 commit comments

Comments
 (0)