일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
- 프로그래머스
- create-next-app
- 중첩 점
- 통신망분석
- 호텔 대실
- nextjs-performance
- 연결 요소 제거하기
- 귤 고르기
- mutationobserver
- Leetcode #javascript #알고리즘 #Algorithms #js
- 헤르메스 엔진
- nextjs
- 리액트네이티브
- Hermes Engine
- jest
- 구름톤
- 테스트 Date
- 날짜 테스트
- 과제 진행하기
- JavaScript
- ResizeObserver
- mock date
- 테이블 해시 함수
- 구름톤챌린지
- 최솟갑 구하기
- 구름톤 챌린지
- Jest uuid syntax
- 리액트네이티브 엔진
- 자바스크립트
- Google 애널리틱스
- Today
- Total
나만보는개발공부블로그
[RN] 코드푸시 DevInternalSettings is not public in com.facebook.react.devsupport 에러 해결방법 본문
[RN] 코드푸시 DevInternalSettings is not public in com.facebook.react.devsupport 에러 해결방법
alexrider94 2024. 1. 17. 15:11최근 codepush 라이브러리를 적용하는데 있어서 안드로이드에서 예전 레퍼런스라서 최근 react-native kotlin으로 만들어진 파일내에서 처리하는 방법은 어떻게 하는지 알아봤습니다.
문서에는 아래와 같이 java파일을 수정하라고 설명되어있는데
// 1. Import the plugin class.
import com.microsoft.codepush.react.CodePush;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
...
// 2. Override the getJSBundleFile method to let
// the CodePush runtime determine where to get the JS
// bundle location from on each app start
@Override
protected String getJSBundleFile() {
return CodePush.getJSBundleFile();
}
};
}
현재는 MainApplication.kt으로 만들어져 있어서 위의 내용과 다르지만 아래와 같이 추가하면 됩니다.
import com.microsoft.codepush.react.CodePush;
...
override val reactNativeHost: ReactNativeHost =
object : DefaultReactNativeHost(this) {
override fun getPackages(): List<ReactPackage> {
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
return PackageList(this).packages
}
override fun getJSMainModuleName(): String = "index"
override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
override fun getJSBundleFile(): String = CodePush.getJSBundleFile()
override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
}
...
위의 방식대로 구성하고 build를 돌리면 제목과 같은 에러가 발생하는데, 현재 react-native 0.73.1 버전과 react-native-code-push 최신버전에서 android 모듈내의 패키지 임포트 문제인것같습니다.
git 이슈를 찾아본 결과, 아래처럼 해결하시면 됩니다.
먼저 patch를 적용해야하는데,
1. patch-package를 설치하고, 아래 코드 실행. 첫번째의 경우 직접 수정하고 두번째 명령어로 patch파일을 생성합니다. (현재 리액트 네이티브 프로젝트 루트 디렉토리에서 진행)
# 1. 노드모듈안의 코드푸시 자바 파일 임포트 수정
vim node_modules/react-native-code-push/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java
# 2. run patch-package으로 패치 파일 생성
npx patch-package react-native-code-push
2. 현프로젝트루트/patches/react-native-code-push+8.1.1.patch와 같은 파일이 생성됬을텐데 위의 1번을 진행안했다면 아래 코드 덮어쓰기.
diff --git a/node_modules/react-native-code-push/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java b/node_modules/react-native-code-push/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java
index 923dd15..91f8ac8 100644
--- a/node_modules/react-native-code-push/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java
+++ b/node_modules/react-native-code-push/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java
@@ -10,7 +10,8 @@ import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
-import com.facebook.react.devsupport.DevInternalSettings;
+//import com.facebook.react.devsupport.DevInternalSettings;
+import com.facebook.react.devsupport.DevSettingsActivity;
import com.facebook.react.devsupport.interfaces.DevSupportManager;
import com.facebook.react.uimanager.ViewManager;
@@ -152,7 +153,7 @@ public class CodePush implements ReactPackage {
if (instanceManager != null) {
DevSupportManager devSupportManager = instanceManager.getDevSupportManager();
if (devSupportManager != null) {
- DevInternalSettings devInternalSettings = (DevInternalSettings)devSupportManager.getDevSettings();
+ DevSettingsActivity devInternalSettings = (DevSettingsActivity)devSupportManager.getDevSettings();
Method[] methods = devInternalSettings.getClass().getMethods();
for (Method m : methods) {
if (m.getName().equals("isReloadOnJSChangeEnabled")) {
3. 아래 코드 패키지에 추가하고 (필요한지 모르겠음..), 아래 명령어 실행.
"scripts": {
...
"postinstall": "patch-package"
...
}
yarn add patch-package postinstall-postinstall
4. 패치 적용되고 다시 안드로이드 빌드하면 성공할겁니다.
참고 링크
https://github.com/microsoft/react-native-code-push/issues/2631
https://github.com/ds300/patch-package#readme
'Web Development > Front' 카테고리의 다른 글
serverless-image-handler 적용하기 (0) | 2024.02.28 |
---|---|
[RN] react-native-nmap Component 'RCTView' re-registered direct event 'topClick' as a bubbling event 에러 (0) | 2024.01.21 |
[RN] 리액트네이티브 카카오 소셜 로그인 (0) | 2024.01.14 |
[RN] 리액트 네이티브에서 환경 변수 처리 (1) | 2024.01.09 |
프론트엔드관점에서 헤더 보안 처리 (0) | 2023.12.04 |