패키지에 있는 그래들 버전이 낮아서 안드로이드에서 앱이 실행되지 않는 현상이 발생되었다...!!!
8로 업데이트 되었을 때 중요한 점이 namespace가 필수인 것..!
업데이트를 할 때에는 안드로이드 스튜디오에서 진행하였다.
시행착오 끝에 해결된 방법을 적어본다.
1. build.gradle 파일에서
- buildToolsVersion = "34.0.0"
- compileSdkVersion = 34
- targetSdkVersion = 34
변경한다.
2. gradle-wrapper.properties 파일에서
- distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-all.zip
내가 올리고자 하는 버전으로 변경
우선 이렇게 하고 ./gradlew clean을 진행했을 때
What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin 'com.android.internal.application'.
> cohttp://m.android.builder.errors.EvalIssueException: The option 'android.disableAutomaticComponentCreation' is deprecated.
It was removed in version 8.0 of the Android Gradle plugin.
Please remove it from `gradle.properties`.
이런 에러가 발생한다.
여기서 볼 것은 발생한 패키지의 이름과 내용
>> 해결 :
-gradle.properties 파일에서
#android.disableAutomaticComponentCreation=true // 주석!
다시 ./gradlew clean
또 다른 에러
A problem occurred configuring project ':app'.
> com.android.builder.errors.EvalIssueException: defaultConfig contains custom BuildConfig fields, but the feature is disabled.
To enable the feature, add the following to your module-level build.gradle:
`android.buildFeatures.buildConfig true`
>> 해결 :
-app/build.gradle 파일에서
buildFeatures {
viewBinding = true
buildConfig=true //이거 추가
}
buildFeatures가 없다면
buildFeatures {
buildConfig=true
} 이렇게 추가한다.
다시 ./gradlew clean
지금부터는 두 가지 경우의 에러가 패키지마다 발생하였다.
이때 안드로이드 스튜디오에서 해당 패키지마다 build.gradle 파일을 찾아 추가해 주거나 변경해주어야 하는데,
이때 파일 보기를 "Project"로 변경하면 해당 패키지를 찾기가 훨씬 쉬워진다.
발생한 에러 첫 번째
* What went wrong:
A problem occurred configuring project ':react-native-picker_picker'.
> com.android.builder.errors.EvalIssueException: defaultConfig contains custom BuildConfig fields, but the feature is disabled.
To enable the feature, add the following to your module-level build.gradle:
`android.buildFeatures.buildConfig true`
해결>> 해당 패키지에 있는 build.gradle 파일에서
android 블록 안에
namespace와 buildFeatures를 추가한다
네임스페이스는 해당 패키지의 이름으로, 보통 src> main> AndroidManifest.xml 파일에 있는 이름이다.
발생한 에러 두 번째
What went wrong:
A problem occurred configuring project ':react-native-seoul_naver-login'.
> Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl.
> Namespace not specified. Specify a namespace in the module's build file. See https://d.android.com/r/tools/upgrade-assistant/set-namespace for information about setting the namespace.
해결>>
해당 패키지에 있는 build.gradle 파일에서
android 블록 안에
namespace를 추가한다
이렇게 namespace만 넣는다.
이렇게 하나하나 clean을 진행하다 보면
BUILD SUCCESSFUL in 3m 44s
드디어 이 메시지를 만나게 될 것이다.!!
## 이건 아직 명확히 해결 안 되는 문제.
그래들 버전을 34로 올리면 빌드는 잘 되지만, 터미널에 metro v0.76.7에 코드가 표시되지 않는다.....ㅠ.ㅠ
이때는 app에서 그래들 버전을 다시 33으로 낮춘다.
1. build.gradle 파일에서
- buildToolsVersion = "33.0.0"
- compileSdkVersion = 33
- targetSdkVersion = 33
(왜인지는 모르겠지만 33으로 낮추면 코드가 보인다. 아마 호환이 안되는것 같다. 메트로 버전은 어떻게 맞추는지 아직 모르겠어서 공부하며 찾아봐야겠다.)
그리고 배포할 때에는 다시 34로 올려서 빌드한다!
'Development > ReactNative' 카테고리의 다른 글
[study] WebView->React->특정 Url 로 이동하는 방법 (1) | 2024.11.27 |
---|---|
[study] ios에서 스크롤 튕기는 효과 없애는 방법 (0) | 2024.07.05 |
[study] 앱 최적화 방법 (0) | 2024.03.25 |
[study] ThunkAction (0) | 2024.03.25 |
[study] png 파일 사용, 이미지 파일의 내용을 변경했음에도 불구하고, 변경 전 이미지가 표시되는 이유 (0) | 2024.03.25 |