본문 바로가기

React-native/update

[ React Native ] [ Android ] bundleRelease 실패 해결 > Task :react-native-async-storage_async-storage:generateReleaseRFile FAILED

> Task :react-native-async-storage_async-storage:generateReleaseRFile FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-async-storage_async-storage:generateReleaseRFile'.
> Could not resolve all files for configuration ':react-native-async-storage_async-storage:releaseCompileClasspath'.
   > Failed to transform react-native-0.71.0-rc.0-release.aar (com.facebook.react:react-native:0.71.0-rc.0) to match attributes {artifactType=android-symbol-with-package-name, com.android.build.api.attributes.BuildTypeAttr=release, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-api}.
      > Could not find react-native-0.71.0-rc.0-release.aar (com.facebook.react:react-native:0.71.0-rc.0).
        Searched in the following locations:
            https://repo.maven.apache.org/maven2/com/facebook/react/react-native/0.71.0-rc.0/react-native-0.71.0-rc.0-release.aar

리엑트 네이티브가 최신 버전으로 업데이트 되면서 생긴 에러 같음 평소대로 bundleRelease를 했지만 실패함

 

참고링크

https://github.com/facebook/react-native/issues/35210

 

[FIXED] Android build failures `No matching variant of com.facebook.react:react-native:0.71.0-rc.0 was found.` · Issue #35210

Description Hey all, I'd like to share an update on a series of build failures React Native & Expo users have been experiencing when building Android apps starting from November 4th 2022. W...

github.com

 

문제해결

android/buld.gradle 에서 allprojects 여기 안에 아래 코드 추가

def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())

allprojects {
    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
        }
    }