change compileSdkVersion and targetSdkVersion to 31

Hello I’m using SDK 44 and eas-cli/0.45.1 darwin-x64 node-v14.17.2.
I’m trying to install the popular library blurhash (latest version)

Here’s the error I get right now:

 FAILURE: Build failed with an exception.
[stderr] * What went wrong:
[stderr] Execution failed for task ':app:checkDebugAarMetadata'.
[stderr] > Multiple task action failures occurred:
[stderr]    > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
[stderr]       > The minCompileSdk (31) specified in a
[stderr]         dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
[stderr]         is greater than this module's compileSdkVersion (android-30).
[stderr]         Dependency: androidx.lifecycle:lifecycle-runtime-ktx:2.4.0.
[stderr]         AAR metadata file: /root/.gradle/caches/transforms-3/526e05f94a98585fc93d6fc42ce9d642/transformed/jetified-lifecycle-runtime-ktx-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
[stderr]    > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
[stderr]       > The minCompileSdk (31) specified in a
[stderr]         dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
[stderr]         is greater than this module's compileSdkVersion (android-30).
[stderr]         Dependency: androidx.lifecycle:lifecycle-runtime:2.4.0.
[stderr]         AAR metadata file: /root/.gradle/caches/transforms-3/f1ce98d93bc25fde929ba697c920acc7/transformed/lifecycle-runtime-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
[stderr] * Try:
[stderr] Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
[stderr] * Get more help at https://help.gradle.org
[stderr] BUILD FAILED in 1m 54s

So after some searching looks like I have to modify the build.gradle to change compileSdkVersion and targetSdkVersion to 31, is there any other way than writing a config plugin?

config plugin is a good way to do it, or you can try changing it in blurhash using patch-package, or you can use an older version of blurhash

Thank you using this patch, the build passed :slight_smile:

diff --git a/node_modules/react-native-blurhash/android/build.gradle b/node_modules/react-native-blurhash/android/build.gradle
index d1edda0..bd35166 100644
--- a/node_modules/react-native-blurhash/android/build.gradle
+++ b/node_modules/react-native-blurhash/android/build.gradle
@@ -27,10 +27,10 @@ def getExtOrIntegerDefault(name) {
 }
 
 android {
-    compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
+    compileSdkVersion 31
     defaultConfig {
         minSdkVersion 16
-        targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
+        targetSdkVersion 31
         versionCode 1
         versionName "1.0"
     }
@@ -125,5 +125,5 @@ dependencies {
     // noinspection GradleDynamicVersion
     api 'com.facebook.react:react-native:+'
     implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
-    implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.4.0"
+    implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.3.1"
 }

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

These days it’s possible to do this without writing your own plugin:

1 Like

With SDK 45 it’s even easier:

2 Likes