diff --git a/README.md b/README.md index e97a643..9001c48 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,33 @@ The Approov integration is available via [`maven`](https://mvnrepository.com/rep 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: ``` -implementation("io.approov:service.httpsurlconn:3.5.3") +implementation("io.approov:service.httpsurlconn:3.5.4") +``` + +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: + +``` +android { + defaultConfig { + minSdkVersion 23 + } + compileOptions { + coreLibraryDesugaringEnabled true + } +} + +dependencies { + coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.4' +} +``` + +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`. + +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: + +``` +-dontwarn com.google.android.gms.tasks.** +-dontwarn com.google.android.play.core.integrity.** ``` 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 ``` -Note that the minimum SDK version you can use with the Approov package is 21 (Android 5.0). +Note that the minimum SDK version you can use with the Approov package is 23 (Android 6.0). 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. diff --git a/SHAPES-EXAMPLE.md b/SHAPES-EXAMPLE.md index ead6c8a..bf10408 100644 --- a/SHAPES-EXAMPLE.md +++ b/SHAPES-EXAMPLE.md @@ -5,7 +5,7 @@ This quickstart is written specifically for native Android apps that are written ## WHAT YOU WILL NEED * Access to a trial or paid Approov account * The `approov` command line tool [installed](https://approov.io/docs/latest/approov-installation/) with access to your account -* [Android Studio](https://developer.android.com/studio) installed (Android Studio Bumblebee 2021.1.1 is used in this guide) +* [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. * The contents of this repo ## RUNNING THE SHAPES APP WITHOUT APPROOV @@ -45,9 +45,11 @@ The `approov-service-httpsurlconn` dependency needs to be added as follows to th ![App Build Gradle](readme-images/app-gradle.png) ``` -implementation("io.approov:service.httpsurlconn:3.5.3") +implementation("io.approov:service.httpsurlconn:3.5.4") ``` +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). + 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. 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. diff --git a/shapes-app/app/build.gradle b/shapes-app/app/build.gradle index 1f496e7..d3690b4 100644 --- a/shapes-app/app/build.gradle +++ b/shapes-app/app/build.gradle @@ -1,11 +1,12 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 31 + namespace "io.approov.shapes" + compileSdkVersion 35 defaultConfig { applicationId "io.approov.shapes" - minSdkVersion 21 - targetSdkVersion 31 + minSdkVersion 23 + targetSdkVersion 34 versionCode 3 versionName "3.0" } @@ -27,11 +28,14 @@ android { compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 + // Required by io.approov:service.httpsurlconn 3.5.4 and later + coreLibraryDesugaringEnabled true } } } dependencies { + coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.4' implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'androidx.appcompat:appcompat:1.4.1' } diff --git a/shapes-app/app/proguard-rules.pro b/shapes-app/app/proguard-rules.pro index f185b4d..5f35773 100644 --- a/shapes-app/app/proguard-rules.pro +++ b/shapes-app/app/proguard-rules.pro @@ -16,3 +16,9 @@ # public *; #} -keep class com.criticalblue.approovsdk.** {*;} + +# The Approov SDK refers to optional Google Play services and Play Integrity classes that +# are not present unless the app includes those libraries. Android Gradle plugin 8 treats +# missing classes as an error in R8. +-dontwarn com.google.android.gms.tasks.** +-dontwarn com.google.android.play.core.integrity.** diff --git a/shapes-app/app/src/main/AndroidManifest.xml b/shapes-app/app/src/main/AndroidManifest.xml index 4780fdd..3b66e07 100644 --- a/shapes-app/app/src/main/AndroidManifest.xml +++ b/shapes-app/app/src/main/AndroidManifest.xml @@ -1,6 +1,5 @@ - + diff --git a/shapes-app/build.gradle b/shapes-app/build.gradle index 8fb329d..8d721f0 100644 --- a/shapes-app/build.gradle +++ b/shapes-app/build.gradle @@ -8,7 +8,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.1.1' + classpath 'com.android.tools.build:gradle:8.9.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } diff --git a/shapes-app/gradle/wrapper/gradle-wrapper.properties b/shapes-app/gradle/wrapper/gradle-wrapper.properties index 63deabe..31dc497 100644 --- a/shapes-app/gradle/wrapper/gradle-wrapper.properties +++ b/shapes-app/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip