From 4c2e7607a288c683c8b9ed67b28a8b4d93692f33 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 19 Jun 2024 14:13:49 +0200 Subject: [PATCH] Add support for AGP 8.4 (#120) * android: bump minSdkVersion to 21 Fixes the following error with AGP 8.4: A problem occurred configuring project ':webcrypto'. > [CXX1110] Platform version 16 is unsupported by this NDK. Please change minSdk to at least 21 to avoid undefined behavior. To suppress this error, add android.ndk.suppressMinSdkVersionError=21 to the project's gradle.properties or set android.experimentalProperties["android.ndk.suppressMinSdkVersionError"]=21 in the Gradle build file. * android: drop package attribute from AndroidManifest.xml Fixes the following error with AGP 8.4: Execution failed for task ':webcrypto:processReleaseManifest'. > A failure occurred while executing com.android.build.gradle.tasks.ProcessLibraryManifest$ProcessLibWorkAction > Incorrect package="com.example.webcrypto" found in source AndroidManifest.xml: /home/simon/src/webcrypto.dart/android/src/main/AndroidManifest.xml. Setting the namespace via the package attribute in the source AndroidManifest.xml is no longer supported. Recommendation: remove package="com.example.webcrypto" from the source AndroidManifest.xml: /home/simon/src/webcrypto.dart/android/src/main/AndroidManifest.xml. * example: build.gradle automatic upgrade These changes are made automatically by the flutter tool when running "flutter build apk". * example: upgrade to AGP 8.4 This is done via the Android Studio AGP upgrade assistant. * ci: upgrade Java to version 21 Java 11 is not new enough for AGP 8.4. --- .github/workflows/test.yml | 4 ++++ android/build.gradle | 7 ++----- android/src/main/AndroidManifest.xml | 3 +-- example/android/app/build.gradle | 3 ++- example/android/app/src/debug/AndroidManifest.xml | 3 +-- example/android/app/src/main/AndroidManifest.xml | 3 +-- example/android/app/src/profile/AndroidManifest.xml | 3 +-- example/android/build.gradle | 6 +++--- example/android/gradle.properties | 3 +++ example/android/gradle/wrapper/gradle-wrapper.properties | 2 +- 10 files changed, 19 insertions(+), 18 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 14108094..a6a88353 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -121,6 +121,10 @@ jobs: with: channel: 'stable' cache: true + - uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: 21 - name: Configure Flutter run: | flutter config --no-analytics diff --git a/android/build.gradle b/android/build.gradle index f28ee5fb..615844ce 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -25,10 +25,7 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - // Conditional for compatibility with AGP <4.2. - if (project.android.hasProperty("namespace")) { - namespace 'dev.google.webcrypto' - } + namespace 'dev.google.webcrypto' compileSdkVersion 31 @@ -53,7 +50,7 @@ android { } defaultConfig { - minSdkVersion 16 + minSdkVersion 21 ndk { abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' } diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index 06c43a03..4438c79a 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -14,6 +14,5 @@ limitations under the License. --> - + diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 856a1cd5..0a9de12b 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -45,7 +45,7 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.example.webcrypto_example" - minSdkVersion 16 + minSdkVersion flutter.minSdkVersion targetSdkVersion 31 versionCode flutterVersionCode.toInteger() versionName flutterVersionName @@ -58,6 +58,7 @@ android { signingConfig signingConfigs.debug } } + namespace 'com.example.webcrypto_example' } flutter { diff --git a/example/android/app/src/debug/AndroidManifest.xml b/example/android/app/src/debug/AndroidManifest.xml index 805c372c..9cadc7e1 100644 --- a/example/android/app/src/debug/AndroidManifest.xml +++ b/example/android/app/src/debug/AndroidManifest.xml @@ -14,8 +14,7 @@ limitations under the License. --> - + - + - +