React Native 빌드 에러 (4)
안드로이드
1. Execution failed for task ':app:lintVitalRelease'
여기서 lintVitalRelease
는 안드로이드 코드 (Java 혹은 Kotlin) 에 대한 lint 를 실행하는 태스크인 듯 싶다.
좀 더 자세한 에러 메시지를 알고 싶으면 Android Studio 에서 lintVatalRelease
를 직접 실행시키면 된다. 하지만 외부 라이브러리의 lint 에러일 가능성이 높으므로 직접 대응하기 힘들 가능성이 높다. (내 경우에도 외부 라이브러리에서 발생한 에러였다.) 물론 그럼에도 근본적인 원인을 찾아 해결하고 싶다면 확인해보자.
"일단은 lint 에러라면 무시해도 되지 않을까?" 라는 접근법으로 해결해보았다. android/app/build.gradle
에 아래 내용을 추가해주면 된다.
android {
// ...
lintOptions {
checkReleaseBuilds false
}
// ...
}
참고
- Error: Execution failed for task ':app: lintVitalRelease' any one can solve it?
- 안드로이드 스튜디오 4.2 Gradle View 에서 Task 목록이 안보일때
2. Execution failed for task ':react-native-screens:compileDebugKotlin'.
최근에 라이브러리를 업데이트한 적도 없고 건드린 적도 없(다고 생각되)는데 별안간 에러가 튀어나왔다. 메시지를 좀 더 길게 보자면 아래와 같다.
e: /Users/kangseong/workspace/dataknows/RichgoInvestment/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/events/StackFinishTransitioningEvent.kt: (14, 25): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.4.0. The class is loaded from /Users/kangseong/.gradle/caches/transforms-3/252e845837c589e4d31b82ce412d387f/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
FAILURE: Build failed with an exception.
* What went wrong: Execution failed for task ':react-native-screens:compileDebugKotlin'.
kotlin 버전 이야기가 나온다. 이상하다. 나는 관련해서 뭔가를 업데이트한 적이 없는(것 같은)데. 여하튼 고쳐보자. android/build.gradle
파일에서 kotiln 버전을 지정해줬다.
// android/build.gradle
buildscript {
ext {
// ...
kotlinVersion = "1.6.10"
}
// ...
수정하니까 일단 에러 메시지는 없어졌다. 그런데 다른 에러가 튀어나왔다.
Execution failed for task ':app:mergeDebugNativeLibs'.
좀 더 길게 보자
* What went wrong: Execution failed for task ':app:mergeDebugNativeLibs'. > A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction > 2 files found with path 'lib/armeabi-v7a/libc++_shared.so' from inputs:
이 에러에 대해서는 구글링 결과 해결책이 두 개 발견되었다.
하나는 android/app/build.gradle
파일에 packagingOptions
를 추가하는 것이다.
// android/app/build.gradle`
android {
// ...
packagingOptions {
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
pickFirst 'lib/x86/libfbjni.so'
pickFirst 'lib/x86/libc++_shared.so'
pickFirst 'lib/arm64-v8a/libfbjni.so'
pickFirst 'lib/arm64-v8a/libc++_shared.so'
pickFirst 'lib/x86_64/libfbjni.so'
pickFirst 'lib/x86_64/libc++_shared.so'
pickFirst 'lib/armeabi-v7a/libfbjni.so'
}
// ...
이 방법으로 빌드 에러는 제거되었다. 그런데 앱을 실행하면 실행하자마자 죽는 문제가 있었다. 그래서 두 번째 방법을 쓰게 되었다.
두 번째 방법은 android/build.gradle
파일에 resolutionStrategy
항목을 추가하는 것이다.
allprojects {
// ...
configurations.all {
resolutionStrategy {
force 'com.facebook.react:react-native:0.66.4' // 설치되어있는 react-native 버전과 동일하게
}
}
}
이렇게 하니까 이제 앱이 잘 실행된다.