mrousavy / react-native-blurhash

🖼️ A library to show colorful blurry placeholders while your content loads.
https://blurha.sh
MIT License
1.98k stars 70 forks source link

Android build fails - The minCompileSdk (31) specified in a dependency's AAR metadata #145

Closed Stevemoretz closed 2 years ago

Stevemoretz commented 2 years ago

Bug

Describe the bug A clear and concise description of what the bug is. Here's the full error while building:

[stderr] 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 50s

To Reproduce Steps to reproduce the behavior:

  1. Just install and build it on expo sdk 44 (using EAS)

Expected behavior No errors.

Screenshots Not needed really.

(Optional) Proposed solution I think the problem comes from this : https://github.com/mrousavy/react-native-blurhash/blob/bd4faacb7e945b0690ccb25ea235960203c9eef2/android/build.gradle#L33 which uses https://github.com/mrousavy/react-native-blurhash/blob/bd4faacb7e945b0690ccb25ea235960203c9eef2/android/build.gradle#L25 that is probably returning 31, which shouldn't.

Environment

Additional context I'm using EAS service from expo for building, builds fine after removing this library but not before.

System:
    OS: macOS 10.15.7
    CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
    Memory: 264.32 MB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 14.17.2 - /usr/local/opt/node@14/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 6.14.13 - /usr/local/opt/node@14/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: Not Found
  SDKs:
    iOS SDK:
      Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
    Android SDK: Not Found
  IDEs:
    Android Studio: 4.0 AI-193.6911.18.40.6626763
    Xcode: 12.4/12D4e - /usr/bin/xcodebuild
  Languages:
    Java: Not Found
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.1 => 17.0.1 
    react-native: 0.64.3 => 0.64.3 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found
    "react": "17.0.1",
    "react-native": "0.64.3",
    "react-native-blurhash": "1.1.8"
Stevemoretz commented 2 years ago

Fixed via this changed:

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"
 }

Anyways, Thanks for this library :) Loving it.