react native 버전업시 발생하는 트러블슈팅

스마트폰 SDK가 최신버전으로 업그레이드시 npm 을 통해 받은 node_modules들이 예전에 작성하고 업데이트가 안되어 있는 경우 아래처럼 직접
수정해야 하는경우가 발생하여 간단히 정리해봄.

1. 타이머(react-native-background-timer)
1) 위치

node_modules\react-native-background-timer\android\src\main\java\com\ocetnik\timer\

2) 에러내용
Error: Tag name should use a unique prefix followed by a colon …
3) 수정사항

this.wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "rohit_bg_wakelock");

에서

this.wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, " ocetnik:rohit_bg_wakelock");

로 수정

2. 비콘(react-native-beacons-manager)
1) 위치

node_modules\react-native-beacons-manager\android\build.gradle

2) 에러내용
Error: Google Play requires that apps target API level 26 or higher.

3) 수정사항
컴파일버전, 타겟버전 26(최소버전)으로 수정

compileSdkVersion 26
targetSdkVersion 26
compile 'com.facebook.react:react-native:0.12.+'

을 아래와 같이 수정

compile "com.facebook.react:react-native:+"

3. 오리엔테이션(react-native-orientation)
1) 위치

node_modules\react-native-orientation\android\build.gradle:9: 

2) 에러내용
Error: Google Play requires that apps target API level 26 or higher.

3) 수정사항

   [ExpiredTargetSdkVersion]
      targetSdkVersion 22

커파일버전, 타겟버전 28(최소버전)으로 수정

compileSdkVersion 28
targetSdkVersion 28

4. 폰 깨우는기능(react-native-wakeful)
1) 위치
node_modules\react-native-wakeful\android\src\main\java\com\ironsmile\RNWakeful\RNWakefulModule.java:25:

2) 에러내용
Error: Tag name should use a unique prefix followed by a colon (found RNWakeful). For instance myapp:mywakelocktag. This will help with debugging [InvalidWakeLockTag]

3) 수정사항

this.wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "RNWakeful");
…
this.wifiLock = wm.createWifiLock(WifiManager.WIFI_MODE_FULL, "RNWakefulWifi");

에서

this.wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "ironsmile:RNWakeful");
…
this.wifiLock = wm.createWifiLock(WifiManager.WIFI_MODE_FULL, "ironsmile:RNWakefulWifi");

로 수정

5. 폰 깨우는기능(react-native-wakeful) Gradle에러
1) 위치
node_modules\react-native-wakeful\android\build.gradle

2) 에러내용
Error: Google Play requires that apps target API level 26 or higher.

3) 수정사항

   [ExpiredTargetSdkVersion]
      targetSdkVersion 23
      ~~~~~~~~~~~~~~~~~~~

커파일버전, 타겟버전 26으로 수정

compileSdkVersion 28
targetSdkVersion 28
compile 'com.facebook.react:react-native:0.12.+'

을 아래와 같이 수정

compile "com.facebook.react:react-native:+"

6. 폰 깨우는기능(react-native-wakeful) React Native Plugin 에러
1) 위치
node_modules\react-native-wakeful\android\src\main\java\com\ironsmile\RNWakeful\RNWakefulPackage.java

2) 에러내용

3) 수정사항

@Override
public List> createJSModules() {
    return Collections.emptyList();
  }

에서 @Override 를 주석처리

// @Override
public List> createJSModules() {
    return Collections.emptyList();
  }

7. 메트로 관련(blacklist.js)
이 항목은 react-native를 먼저 업데이트 하면 안나오지만, 업데이트 안한경우 아래처럼 수정해서 해결
1) 위치
node_modules\metro-config\src\defaults\blacklist.js

2) 수정사항

var sharedBlacklist = [
  /node_modules[/\\]react[/\\]dist[/\\].*/,
  /website\/node_modules\/.*/,
  /heapCapture\/bundle\.js/,
  /.*\/__tests__\/.*/
];

에서

var sharedBlacklist = [ /node_modules[\/\\]react[\/\\]dist[\/\\].*/, /website\/node_modules\/.*/, /heapCapture\/bundle\.js/, /.*\/__tests__\/.*/ ];

로 수정

8. 디바이스정보
React-native-device-info는 최신버전이 나와 있어 업데이트 하면 되지만 업데이트를 안할경우 아래를 수정
1) 위치
node_modules\react-native-device-info\android\src\main\java\com\learnium\RNDeviceInfo\RNDeviceModule.java:270:

2) 에러내용
Error: Exception requires API level 21 (current min is 16): android.hardware.camera2.CameraAccessException, and having a surrounding/preceding version check does not help since prior to API level 19, just loading the class will cause a crash. Consider marking the surrounding class with RequiresApi(19) to ensure that the class is never loaded except when on API 19 or higher. [NewApi] } catch (CameraAccessException e) {
~~~~~~~~~~~~~~~~~~~~~

3) 수정사항
“react-native-device-info”: “^2.3.2” 를 제거하고

npm uninstall react-native-device-info

최신버전 설치(5.5.4 버전으로 체인지)

npm install react-native-device-info --save

9. build.Gradle 환경
1) 수정사항
컴파일오류로 인하여 아래처러 수정

플레이서비스와 Firebase의 버전이 동일해야 하므로 동일하게 맞춤

implementation "com.google.android.gms:play-services-location:17.0.0"
implementation "com.google.android.gms:play-services-base:16.1.0"
implementation "com.google.firebase:firebase-core:16.0.9"

implementation "com.google.android.gms:play-services-location:17.0.0"
implementation "com.google.android.gms:play-services-base:17.0.0"
implementation "com.google.firebase:firebase-core:17.0.0"

로 수정

10. react-native 최신버전 업데이트
1) 에러내용
아래 에러로 인하여 업데이트 처리

error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually:
  - react-native-device-info (to unlink run: "react-native unlink react-native-device-info")
This is likely happening when upgrading React Native from below 0.60 to 0.60 or above. Going forward, 
you can unlink this dependency via "react-native unlink " and it will be included in your app automatically. 
If a library isn't compatible with autolinking, disregard this message and notify the library maintainers.

2) 수정사항
– 캐시 클린

npm cache clean --force

– react-native 버전 0.60.4을 제거

npm uninstall react-native

– 신버전 설치(0.62.0)

npm install react-native --save

11. async-storage 최신버전 업데이트
1) 에러내용
메소드 사용방법변경으로 오류

2) 수정사항
신버전 업데이트

– 제거

npm uninstall @react-native-community/async-storage

– 신버전설치(1.8.1)

npm install @react-native-community/async-storage –save

12. react-native 업데이트후 앱 크래쉬 나온경우
1) 에러내용

2020-04-01 15:06:38.177 12257-12285/? E/AndroidRuntime: FATAL EXCEPTION: create_react_context
    Process: kr.co.transhub, PID: 12257
    java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libfbjni.so caused by: Didn't find class "com.facebook.jni.NativeRunnable" on path: DexPathList[[zip file "/data/app/kr.co.transhub-VszmjqWt0xirxB8bmxGG2A==/base.apk"],nativeLibraryDirectories=[/data/app/kr.co.transhub-VszmjqWt0xirxB8bmxGG2A==/lib/arm64, /data/app/kr.co.transhub-VszmjqWt0xirxB8bmxGG2A==/base.apk!/lib/arm64-v8a, /system/lib64]]
        at com.facebook.soloader.SoLoader.a(Unknown Source:325)
        at com.facebook.soloader.SoLoader.a(Unknown Source:104)
        at com.facebook.soloader.SoLoader.a(Unknown Source:108)
        at com.facebook.soloader.SoLoader.a(Unknown Source:1)
        at com.facebook.soloader.j.a(Unknown Source:0)
        at com.facebook.soloader.o.a.a(Unknown Source:10)
        at com.facebook.jni.HybridData.(Unknown Source:2)
        at com.facebook.react.bridge.WritableNativeMap.initHybrid(Native Method)
        at com.facebook.react.bridge.WritableNativeMap.(Unknown Source:0)
        at com.facebook.react.jscexecutor.a.create(Unknown Source:2)
        at d.b.m.r$e.run(Unknown Source:58)
        at java.lang.Thread.run(Thread.java:764)

2) 수정사항
proguard-rules.pro파일의 하단에 아래를 추가

-keep class com.facebook.jni.** { *; }

– 참고: https://stackoverflow.com/questions/60927048/react-native-app-release-build-crashes-on-start-works-fine-in-debug-why

태그 , , ,

댓글 남기기

이 사이트는 스팸을 줄이는 아키스밋을 사용합니다. 댓글이 어떻게 처리되는지 알아보십시오.