Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -26,7 +52,7 @@ The following app permissions need to be available in the manifest to use Approo
<uses-permission android:name="android.permission.INTERNET" />
```

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.

Expand Down
6 changes: 4 additions & 2 deletions SHAPES-EXAMPLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
10 changes: 7 additions & 3 deletions shapes-app/app/build.gradle
Original file line number Diff line number Diff line change
@@ -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"
}
Expand All @@ -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'
}
6 changes: 6 additions & 0 deletions shapes-app/app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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.**
3 changes: 1 addition & 2 deletions shapes-app/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.approov.shapes">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Expand Down
2 changes: 1 addition & 1 deletion shapes-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion shapes-app/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading