๐Ÿ“ฑ Mobile

[Windows] React Native ์œˆ๋„์šฐ ํ™˜๊ฒฝ ๊ตฌ์„ฑํ•˜๊ธฐ

sa1t 2024. 12. 23. 16:58

์ตœ๊ทผ์— React Native ์œˆ๋„์šฐ ํ™˜๊ฒฝ ๊ตฌ์„ฑํ•ด์„œ ์–ดํ”Œ ๊ฐœ๋ฐœํ•  ์ผ์ด ์ƒ๊ฒจ์„œ ์‹œ๋„ํ–ˆ๋‹ค.

 

React Native Windows ํ™˜๊ฒฝ ๊ตฌ์„ฑ ์š”์†Œ

1. Node.js ์„ค์น˜

2. React Native CLI ์„ค์น˜

3. JDK ์„ค์น˜

4. ์•ˆ๋“œ๋กœ์ด๋“œ ์ŠคํŠœ๋””์˜ค ์„ค์น˜

5. ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ ๋ฐ ์‹คํ–‰

 

์ค‘๊ฐ„์ค‘๊ฐ„ ์˜ค๋ฅ˜๊ฐ€ ์—„์ฒญ ๋งŽ์ด ๋‚ฌ์–ด์„œ ํ•ด๋‹น ์˜ค๋ฅ˜๊นŒ์ง€ ํ™•์ธํ•  ์˜ˆ์ •

 

1. Node.js ์„ค์น˜

https://nodejs.org/ko/

 

Node.js — ์–ด๋””์„œ๋“  JavaScript๋ฅผ ์‹คํ–‰ํ•˜์„ธ์š”

Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.

nodejs.org

 

ํ•ด๋‹น URL ์—์„œ msi ํŒŒ์ผ ๋‹ค์šด ๋ฐ›๊ณ  ๊ธฐ๋ณธ ์„ค์ •์œผ๋กœ ์„ค์น˜ํ•ด์ค€๋‹ค . ( ๋‹ค์Œ๋‹ค์Œ๋‹ค์Œ ๋ˆŒ๋Ÿฌ์„œ ์„ค์น˜ .. )

 

* ์„ค์น˜ ํ™•์ธํ•˜๊ธฐ

node -v
npm -v

ํ•ด๋‹น ๋ช…๋ น์–ด๋กœ node์™€ npm์ด ์ •์ƒ์ ์œผ๋กœ ์„ค์น˜ ๋˜์—ˆ๋Š”์ง€ ํ™•์ธ ๊ฐ€๋Šฅํ•˜๋‹ค.


2. React-Native-CLI ์„ค์น˜

npm ๋ช…๋ น์–ด๋กœ react-native-cli๋ฅผ ์„ค์น˜ํ•œ๋‹ค.

npm install -g react-native-cli

 

๋ฆฌ์•กํŠธ ๋„ค์ดํ‹ฐ๋ธŒ ๋ฒ„์ „ ํ™•์ธ ๋ช…๋ น์–ด๋กœ ์„ค์น˜๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

npm react-native -v

 


3. JDK ์„ค์น˜

https://p-ssw0rd.tistory.com/115

 

[JAVA/Windows 10 pro] JDK 1.9 ์„ค์น˜ / ํ™˜๊ฒฝ ๋ณ€์ˆ˜ ์„ค์ •

https://www.oracle.com/ Oracle | Cloud Applications and Cloud Platform Oracle customers are changing the world. Let’s celebrate these successes at the CloudWorld party as the legendary Steve Miller Band takes the stage. Secure your spot by registering fo

p-ssw0rd.tistory.com

JDK ์„ค์น˜ ํ™•์ธ์„ ์œ„ํ•ด ๋ฒ„์ „ ํ™•์ธ ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.

java -version
javac -version


4. ์•ˆ๋“œ๋กœ์ด๋“œ ์ŠคํŠœ๋””์˜ค ์„ค์น˜

์•ˆ๋“œ๋กœ์ด๋“œ ๊ธฐ๋ณธ ์„ค์ •์œผ๋กœ ์„ค์น˜์™„๋ฃŒํ•œ๋‹ค.

ํ™˜๊ฒฝ ๋ณ€์ˆ˜ ๊ผญ ์„ค์ •ํ•ด์ค˜์•ผํ•œ๋‹ค.

๋ณ€์ˆ˜ ์ด๋ฆ„ : ANDROID_HOME

๋ณ€์ˆ˜ ๊ฐ’ : C:\Users\ใ…‡ใ…‡ใ…‡\AppData\Local\Android\Sdk

 

path ์„ค์ •

%ANDROID_HOME%\platform-tools

 

adb ๋ฒ„์ „ ํ™•์ธ ๋ช…๋ น์–ด๋กœ ์„ค์น˜ ํ™•์ธํ•ด์ค€๋‹ค.

adb --version

 


 

5. React Native ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ

ํ˜น์‹œ ๋ชจ๋ฅด๋‹ˆ cmd๋ฅผ ๊ด€๋ฆฌ์ž ๋ชจ๋“œ๋กœ ์˜คํ”ˆ ํ›„ ํ”„๋กœ์ ํŠธ ์ƒ์„ฑํ•  ์œ„์น˜์˜ ํด๋”๋กœ ์ด๋™ํ•œ๋‹ค.

C:\Users\chaen>cd C:\Users\chaen\00chaen\calculator
npx react-native init calculator	# calculator ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ

 

์ƒ์„ฑํ•œ ์œ„์น˜์—์„œ ์•ˆ๋“œ๋กœ์ด๋“œ๋ฅผ ์‹คํ–‰ํ•œ๋‹ค.

npm run android

 

์ฒ˜์Œ์— ๋ฌด์Šจ ์ด์ƒํ•œ ์˜ค๋ฅ˜์ธ๋ฐ Gradle์ด ์‹คํŒจํ–ˆ์Œ์„ ๋‚˜ํƒ€๋‚ด๋Š” ์˜ค๋ฅ˜๊ฐ€ ๋‚˜์™”๋‹ค...

BUILD FAILED in 1m 35s
error Failed to install the app. 
Command failed with exit code 1: gradlew.bat app:installDebug 
-PreactNativeDevServerPort=8081 FAILURE: Build failed with an exception. 
* Where: Settings file 'C:\Users\chaen\00chaen\calculator\android\settings.gradle' 
line: 2 * What went wrong: Error resolving plugin [id: 'com.facebook.react.settings'] > 
java.io.UncheckedIOException: Could not move temporary workspace (C:\Users\chaen\00chaen\calculator\android\.gradle\8.10.2\dependencies-accessors\569c8b261a8a714d7731d5f568e0e5c05babae10-d0d44398-45f8-43e9-95d2-6107f9fef694) 
to immutable location (C:\Users\chaen\00chaen\calculator\android\.gradle\8.10.2\dependencies-accessors\569c8b261a8a714d7731d5f568e0e5c05babae10) 
* Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > 
Run with --scan to get full insights. > Get more help at https://help.gradle.org. BUILD FAILED in 1m 35s.
info Run CLI with --verbose flag for more details.

๊ทธ๋ž˜์„œ Gradle ์บ์‹œ ์‚ญ์ œ๋ฅผ ์š”์ฒญํ•จ

gradlew clean

๊ทธ๋žฌ๋”๋‹ˆ ์บ์‹œ ์‚ญ์ œ ์ฃผ๋ฅด๋ฅต ํ•˜๋”๋‹ˆ

 

npx react-native run-android

ํ•ด๋‹น ๋ช…๋ น์–ด ์‹คํ–‰ ์‹œ ์ž˜ ์‹คํ–‰ ๋๋‹ค.

 

node.js์—์„œ๋Š” ์ด๋ ‡๊ฒŒ ๋œฌ๋‹ค

์•ˆ๋“œ๋กœ์ด๋“œ ์—๋ฎฌ๋ ˆ์ดํ„ฐ๋Š” ์ด๋ ‡๊ฒŒ ๋œธ !