/react-native-trouble-shooting

๐Ÿ˜ก react-native๋ฅผ ๊ฐœ๋ฐœํ•˜๋ฉด์„œ ๋งˆ์ฃผ์ณค๋˜ trouble shooting์„ ๋ชจ์•„๋†“์€ ๋ ˆํฌ์ง€ํ† ๋ฆฌ์ž…๋‹ˆ๋‹ค.

MIT LicenseMIT

react-native-trouble-shooting

react-native๋ฅผ ๊ฐœ๋ฐœํ•˜๋ฉด์„œ ๋งˆ์ฃผ์ณค๋˜ trouble shooting์„ ๋ชจ์•„๋†“์€ ๋ ˆํฌ์ง€ํ† ๋ฆฌ์ž…๋‹ˆ๋‹ค.

Android

์•ˆ๋“œ๋กœ์ด๋“œ apk ๋นŒ๋“œํ•  ๋•Œ ๋‚˜๋Š” ์—๋Ÿฌ (Android apk build error)

$ ./gradlew assembleRelease
...
Execution failed for task ':app:processReleaseResources'.

Solution

gradle.properties์— ์•„๋ž˜ ์ฝ”๋“œ๋ฅผ ๋„ฃ๋Š”๋‹ค.

android.enableAapt2=false

์ฃผ์˜์‚ฌํ•ญ: ํ•˜์ง€๋งŒ android.enableAapt2 ์˜ต์…˜์€ 2018๋…„ ๋ง ์ดํ›„๋กœ deprecated๋œ๋‹ค๊ณ  ํ•˜๋‹ˆ ๋‚˜์ค‘์—๋Š” ๋‹ค๋ฅธ ๋ฐฉ๋ฒ•์„ ์ฐพ์•„์•ผํ•  ๊ฒƒ ๊ฐ™๋‹ค.

์ฐธ๊ณ : facebook/react-native#19239

์•ˆ๋“œ๋กœ์ด๋“œ ๋นŒ๋“œํ•  ๋•Œ ๋‹ค์Œ ์—๋Ÿฌ๊ฐ€ ๋œธ

Fatal Exception: java.lang.IllegalStateException: Native module RNDeviceModule tried to override RNDeviceModule for module name RNDeviceInfo. If this was your intention, set canOverrideExistingModule=true
       at com.facebook.react.NativeModuleRegistryBuilder.addNativeModule(NativeModuleRegistryBuilder.java:121)
       at com.facebook.react.NativeModuleRegistryBuilder.processPackage(NativeModuleRegistryBuilder.java:109)
       at com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:1050)
       at com.facebook.react.ReactInstanceManager.processPackages(ReactInstanceManager.java:1021)
       at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:959)
       at com.facebook.react.ReactInstanceManager.access$600(ReactInstanceManager.java:109)
       at com.facebook.react.ReactInstanceManager$4.run(ReactInstanceManager.java:802)
       at java.lang.Thread.run(Thread.java:818)

Solution

MainApplication.java์˜ protected List getPackages() ๋ถ€๋ถ„์—์„œ RNDeviceModule์ด ๋‘ ๋ฒˆ ๋“ค์–ด์žˆ์„ ๊ฒƒ์ด๋‹ค.

์ฐธ๊ณ : react-native-device-info/react-native-device-info#243

์•ˆ๋“œ๋กœ์ด๋“œ์—์„œ canโ€™t not find Symbol ์—๋Ÿฌ

mobx ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์ถ”๊ฐ€ํ•œ ๊ฒƒ์ด ๋ฌธ์ œ์˜ ๋ฐœ๋‹จ์ด์—ˆ์Œ

Solution

JSC๊ฐ€ ์˜ˆ์ „ ๋ฒ„์ „์ด๋ผ ์—๋Ÿฌ๊ฐ€ ๋‚˜๋Š” ๊ฒƒ -> JSC๋ฅผ ์—…๋ฐ์ดํŠธํ•ด์•ผ ํ•œ๋‹ค.

์—…๋ฐ์ดํŠธ ํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

  1. package.json์— jsc-android ์ถ”๊ฐ€ ํ›„ npm install ํ˜น์€ yarn ๋ช…๋ น์–ด๋กœ ์„ค์น˜
dependencies {
+  "jsc-android": "236355.x.x"
  1. android/build.gradle์— ๋‹ค์Œ ์ฝ”๋“œ ์ถ”๊ฐ€
allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
+       maven {
+           // Local Maven repo containing AARs with JSC library built for Android
+           url "$rootDir/../node_modules/jsc-android/dist"
+       }
    }
}
  1. android/app/build.gradle์— ๋‹ค์Œ ์ฝ”๋“œ ์ถ”๊ฐ€
}
 
+configurations.all {
+    resolutionStrategy {
+        force 'org.webkit:android-jsc:r236355'
+    }
+}
 
dependencies {
    compile fileTree(dir: "libs", include: ["*.jar"])
  1. rebuildํ•˜๋ฉด ์—…๋ฐ์ดํŠธ๋œ ๋ฒ„์ „์˜ JSC๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.

์ฐธ๊ณ : https://github.com/react-community/jsc-android-buildscripts#how-to-use-it-with-my-react-native-app

ํŒŒ์ด์–ด๋ฒ ์ด์Šค ๊ด€๋ จ ์•ˆ๋“œ๋กœ์ด๋“œ ๋นŒ๋“œ ์—๋Ÿฌ

์•ˆ๋“œ๋กœ์ด๋“œ์—์„œ ๋นŒ๋“œํ•˜๋ฉด ๋‹ค์Œ ์—๋Ÿฌ ๋ฐœ์ƒ

Program type already present: com.google.android.gms.internal.measurement.zzwp 

Solution

ํŒŒ์ด์–ด๋ฒ ์ด์Šค ์ฝ”์–ด ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์ตœ์‹  ๋ฒ„์ „์œผ๋กœ ์˜ฌ๋ฆฌ๋ฉด ๋œ๋‹ค.

์•ˆ๋“œ๋กœ์ด๋“œ ํŒŒ์ด์–ด๋ฒ ์ด์Šค sdk์˜ ๋ฒ„์ „ ๋ฆฌ์ŠคํŠธ๋Š” ์—ฌ๊ธฐ๋ฅผ ์ฐธ๊ณ ํ•˜๋ฉด ๋œ๋‹ค.

๋งํฌ

์ฐธ๊ณ : https://stackoverflow.com/questions/50146640/android-studio-program-type-already-present-com-google-android-gms-internal-me

Program type already present: android.support.v4.app.INotificationSideChannel

Solution

// build.gradle
buildscript {
    // others...
    ext {
        // others...
        googlePlayServicesVersion = "16.0.0" // Add this
        firebaseVersion = "17.0.0" // Add this
    }
}

iOS

iOS ๋นŒ๋“œ ์ค‘ ์—๋Ÿฌ : Duplicate Module Name: react-name

Solution

Pods ํŒŒ์ผ์„ ์ œ๊ฑฐํ•˜๊ณ  ์ƒˆ๋กœ ์„ค์น˜ํ•œ๋‹ค.

cd ios
rm -rf Pods
pod install

์ฐธ๊ณ : https://stackoverflow.com/questions/50805753/duplicate-module-name-react-native

iOS ๋นŒ๋“œ ์ค‘ ์—๋Ÿฌ - Xcode 10: Build input file double-conversion cannot be found

Solution

๋‹ค์Œ ๋ช…๋ น์–ด๋ฅผ ํ”„๋กœ์ ํŠธ ๋ฃจํŠธ ๊ฒฝ๋กœ์—์„œ ์‹คํ–‰

$ cd node_modules/react-native/scripts && ./ios-install-third-party.sh && cd ../../../
$ cd node_modules/react-native/third-party/glog-0.3.5/ && ../../scripts/ios-configure-glog.sh && cd ../../../../

์ฐธ๊ณ : facebook/react-native#21168

iOS ๋นŒ๋“œ ์—๋Ÿฌ: Undefined symbols for architecture armv7

Solution

CxxBridge, DoubleConversion, Folly, GLog๋ฅผ PodFile์— ์ถ”๊ฐ€

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
 
target 'reactTest' do
  #Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  #use_frameworks!
  #Pod react-native
  react_native = "../node_modules/react-native"
  pod 'React', :path => react_native, :subspecies => [
  'Core',
  'CxxBridge',
  'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
  'RCTText',
  'RCTNetwork',
  'RCTWebSocket', # needed for debugging
  ]
 
  #Pod yoga support for react-native
  pod 'yoga', :path => "#{react_native}/ReactCommon/yoga"
end

์ฐธ๊ณ : facebook/react-native#14925

error: bundling failed: Error: Unable to resolve module ./../react-transform-hmr/lib/index.js

Solution

์บ์‹œ๋ฅผ ํด๋ฆฐํ•ด์•ผ ํ•œ๋‹ค.

rm -rf $TMPDIR/react-*; rm -rf $TMPDIR/haste-*; rm -rf $TMPDIR/metro-*; watchman watch-del-all
 
# Start Metro Bundler directly
react-native start

์ฐธ๊ณ : facebook/react-native#21490

clang: error: no such file or directory: libLocalize.a

Solution

์ฒซ๋ฒˆ์งธ ๋ฐฉ๋ฒ•: xcode ์ข…๋ฃŒ ํ›„, rm -rf ~/Library/Developer/Xcode/DerivedData/* ๋ช…๋ น์–ด ์‹คํ–‰ ํ›„ ๋‹ค์‹œ xcode ์‹คํ–‰

๋‘๋ฒˆ์งธ ๋ฐฉ๋ฒ•: RNLocalize.xcodeproj๋ฅผ libraries์—์„œ ์ œ๊ฑฐํ•œ ๋‹ค์Œ ๋‹ค์‹œ add fileํ•˜๋ฉด ๋จ

์ฐธ๊ณ : react-native-device-info/react-native-device-info#446 (comment)

Javascript

decorator ๊ด€๋ จ ๋นŒ๋“œ ์—๋Ÿฌ

mobx ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด decorator๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ–ˆ์—ˆ๋Š”๋ฐ ๋นŒ๋“œ ๋„์ค‘ ๋‹ค์Œ ์—๋Ÿฌ๊ฐ€ ๋‚ฌ๋‹ค.

Error build-assets - new decorators proposal is not supported yet. You must pass the"legacy": true option

Solution

  1. @babel/plugin-proposal-decorators๋ฅผ ์„ค์น˜
npm install --save-dev @babel/plugin-proposal-decorators
  1. tsconfig.json ํŒŒ์ผ์— ๋‹ค์Œ ๋ผ์ธ์„ ์ž…๋ ฅ
["@babel/plugin-proposal-decorators", { "legacy": true }],

์ฐธ๊ณ : saleor/saleor#2179

Contributing

react-native ๊ด€๋ จ ํŠธ๋Ÿฌ๋ธ” ์ŠˆํŒ… ๊ณต์œ ๋Š” ์–ธ์ œ๋‚˜ ํ™˜์˜์ž…๋‹ˆ๋‹ค!