Androidã¨ãã¥ã¬ã¼ã¿ã§RN製ã¢ããªã®ãããã°ããããã¨æã£ãã®ã§ããããªãã¨ãªãAndroid Studioãç«ã¡ä¸ãã¦ã¨ãã¥ã¬ã¼ã¿ãèµ·åãã¦Runãã¿ã³ãæ¼ãã®ãåå«ã«ãªã£ã¦ãã¾ããæã®èµ´ãã¾ã¾ã«ã³ãã³ãã©ã¤ã³ããã¢ããªãèµ·åãã¦ã¿ã¾ããã
ä½ãèããªãã§æãåãããã ããªã®ã§ããã£ã¨è¯ãæ¹æ³ããããã¨ã¯æãã¾ããèªãã§ãããåãããªãã£ã人ã¯çä¼¼ããAndroid Studioãèµ·åãã¦ãã ããã
ã¨ãã¥ã¬ã¼ã¿ãç«ã¡ä¸ãã
ã¨ãã¥ã¬ã¼ã¿ã®ä½æã¯Android Studioãéããã»ãã楽ã§ãããä½ææ¸ã¿ã®ã¨ãã¥ã¬ã¼ã¿ã¯ã³ãã³ãã©ã¤ã³ããã§ãèµ·åã§ãã¾ãã
$ $ANDROID_HOME/tools/emulator -list-avds # ä½ææ¸ã¿ã®ã¨ãã¥ã¬ã¼ã¿ä¸è¦§ãåºã Nexus_5X_API_26 Pixel_API_24 Pixel_C_API_25 $ $ANDROID_HOME/tools/emulator @Pixel_C_API_25 # ã¨ãã¥ã¬ã¼ã¿ãæå®ãã¦èµ·åãã emulator: emulator window was out of view and was recentered emulator: ### WARNING: /etc/localtime does not point to /usr/share/zoneinfo/, can't determine zoneinfo timezone name emulator: ### WARNING: /etc/localtime does not point to /usr/share/zoneinfo/, can't determine zoneinfo timezone name
æ¬æ¥ã¯ $ANDROID_HOME/tools
ã«ã¯PATHãéãã¦ããã®ã§ããã emulator
ã¨æã¤ã ãã§ãèµ·åã§ãã¾ããã説æã®ããã«åé·ã«ãã¦ããã¾ãã
ããã§ã¨ãã¥ã¬ã¼ã¿ã®èµ·åãå¾ ã¡ã¾ãã
bundlerãã¹ã¿ã¼ããã¦ãã
æçµçã«ã¯ react-native run-android
ã使ãã®ã§ããã®ã¨ãã«ä¸ç·ã«bundlerãç«ã¡ä¸ãã¦ããããã®ã§ããã諸ã
ã®äºæ
ã§yarn startã«åç´ãªstart以å¤ã«ãå¦çãä»è¾¼ãã§ããå ´åãªã©ãããã¨æãã¾ãããã¡ã®å ´åã¯ãã£ãã·ã¥ã«æ©ã¾ããã¦ã¤ããã£ããã¨ããã£ãã®ã§ --reset-cache
ãå¿
ãä»ããããã«ãã¦ãããã¾ãã
ãããªäºæ
ããã run-android
ã¨ã¯å¥ã«bundlerãå®è¡ãã¦ãã¾ããã¿ã¼ããã«ã®ã¿ããã²ã¨ã¤å æããã¦ãããæãã§ããã
$ yarn start yarn run v1.5.1 $ node node_modules/react-native/local-cli/cli.js start --reset-cache Scanning folders for symlinks in /path/to/rnapp/node_modules (51ms) ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ â Running Metro Bundler on port 8081. â â â â Keep Metro Bundler running while developing on any JS projects. Feel â â free to close this tab and run your own Metro Bundler instance if you â â prefer. â â â â https://github.com/facebook/react-native â â â ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ Looking for JS files in /path/to/rnapp Metro Bundler ready. Loading dependency graph, done.
ã¨ãã¥ã¬ã¼ã¿ã®ããã¤ã¹åã確èªãã¦run-androidãã
ã¨ãã¥ã¬ã¼ã¿ã¨bundlerã®æºåãã§ãããããã¨ã¯ã¢ããªãèµ·åããã ãã§ãã
react-native run-android
ã«deviceIdãªãã·ã§ã³ãä»ããã¨ãã¤ã³ã¹ãã¼ã«å
ã®å®æ©ãã¨ãã¥ã¬ã¼ã¿ãæå®ã§ããã®ã§ãå
ç¨èµ·åããã¨ãã¥ã¬ã¼ã¿ã®deviceIdã調ã¹ãã¨ããããå§ãã¾ãã
$ $ANDROID_HOME/platform-tools/adb devices # ã¨ãã¥ã¬ã¼ã¿ãå®æ©ã®deviceIdã調ã¹ã List of devices attached emulator-5554 device # ãããã¨ãã¥ã¬ã¼ã¿ã®deviceId $ npx react-native-cli run-android --deviceId emulator-5554 # Androidã§ã¢ããªãèµ·åãã npx: 41åã®ããã±ã¼ã¸ã4.999ç§ã§ã¤ã³ã¹ãã¼ã«ãã¾ããã Scanning folders for symlinks in /Users/y.nakagawa/dev/an-lite-app/packages/app/node_modules (46ms) JS server already running. Building the app...
adbã§deviceIdã調ã¹ãã¨ã大æµã¯emulartor-5554ãåºã¦ãã¾ããé¢åã§ããã°èª¿ã¹ãã«æ±ºãæã¡ã§emulator-5554ãæå®ãã¦ãããã®ããããã¾ããï¼ã¨ãããããããã¾ãï¼ã
ã³ãã³ãã react-native run-android
ã§ã¯ãªã npx react-native-cli run-android
ã¯ç¹ã«æèã®é«ã話ã§ã¯ãªãããªããºãã©ãªè©±ã§ãä½ã ãé¢åã«ãªã£ã¦react-native-cliãã°ãã¼ãã«ã«ãdevDependenciesã«ãã¤ã³ã¹ãã¼ã«ããªããªã£ã*1ã®ã§ããã®ã¨ãã ã使ããã°ãããã¨ããã¢ããã¼ã·ã§ã³ã§ä½¿ã£ã¦ãã¾ãããã®æ¹æ³ã®åé¡ã¨ãã¦ãyarn startã¨run-androidã§ä½¿ã£ã¦ããcliã®å®è£
ãéã£ã¦ãããã©ããã®ï¼ã¨ãã話ã¯ãã£ã¦ããã¤ãçãç®ãè¦ãããªæ°ã¯ãã¦ãã¾ãã
ã¾ã¨ã
Android SDKã®emulatorãadbã¨ãã£ãã³ãã³ãã®åããæã«æã¿ä»ãã¦ãã人éã¯ããããå¤ãªèµ·åã®ä»æ¹ããããã¨ãããã¾ããããããªãã¨ãæ°ããè¦ããããã«å¦ç¿ã³ã¹ããæãããããªãç´ ç´ã«Android Studioãç«ã¡ä¸ããã»ããè³¢æã ã¨æãã®ã§ãã©ããã¦ããã£ã¦ã¿ããæ¹ä»¥å¤ã¯çä¼¼ããã®ã¯ãªã¹ã¹ã¡ãã¾ããã
*1:ãã¾ã«ãã使ããªããã»ã»ã»