React Native/React Native_error

[React Native - android] The minCompileSdk (31) specified in a dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties) is greater than this module's compileSdkVersion (android-30).

bocoder
728x90
반응형

 

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081 FAILURE: Build failed with an exception.
* What went wrong: Execution failed for task ':app:checkDebugAarMetadata'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (31) specified in a dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties) is greater than this module's compileSdkVersion (android-30). Dependency: androidx.appcompat:appcompat:1.4.1. AAR metadata file: /Users/.../.gradle/caches/transforms-3/f502c72d05399cc65525865f987345c0/transformed/appcompat-1.4.1/META-INF/com/android/build/gradle/aar-metadata.properties.
* Try: 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.
* Get more help at https://help.gradle.org BUILD FAILED in 24s

 

 

# 원인 

: 2022년 11월부터 Android API 31 타게팅이 필수로 변경되면서 발생한 에러

* reference : https://stackoverflow.com/a/74355365

* reference : https://developer.android.com/google/play/requirements/target-sdk?hl=ko 

 

 

# 해결방법

: 나의 경우는 0.65.1 을 사용하고 있었기에  android > build.gradle 에서 아래 내용 추가하여 해결

추가로 스토어 배포를 위해서는 Android API 31 로 변경이 필요함

allprojects {
    repositories {
    ...
    }
    
    // 추가
    configurations.all {
        resolutionStrategy {
            // Remove this override in 0.65+, as a proper fix is included in react-native itself.
            force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
        }
    }
}

 

 

 

 

 

* reference : https://github.com/facebook/react-native/issues/35210#issue-1436785719

* reference : https://react-native-community.github.io/upgrade-helper/?from=0.65.1&to=0.65.3 

 

728x90
반응형