Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
React Native Cookbook

You're reading from   React Native Cookbook Recipes for solving common React Native development problems

Arrow left icon
Product type Paperback
Published in Jan 2019
Publisher Packt
ISBN-13 9781788991926
Length 592 pages
Edition 2nd Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Daniel Ward Daniel Ward
Author Profile Icon Daniel Ward
Daniel Ward
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Preface 1. Setting Up Your Environment FREE CHAPTER 2. Creating a Simple React Native App 3. Implementing Complex User Interfaces - Part I 4. Implementing Complex User Interfaces - Part II 5. Implementing Complex User Interfaces - Part III 6. Adding Basic Animations to Your App 7. Adding Advanced Animations to Your App 8. Working with Application Logic and Data 9. Implementing Redux 10. App Workflow and Third-Party Plugins 11. Adding Native Functionality - Part I 12. Adding Native Functionality - Part II 13. Integration with Native Applications 14. Deploying Your App 15. Optimizing the Performance of Your App 16. Other Books You May Enjoy

Installing Android Studio

Android Studio comes with the official Android emulator, which is the emulator that Expo recommends for use during development.

How to do it...

  1. Download Android Studio from https://developer.android.com/studio/.
  2. Open the downloaded file and drag the Android Studio.app icon to the Applications folder icon:
  1. Once installed, we'll need to change the Android Studio preferences. Open Android Studio, and then open Preferences from the Android Studio menu in the system bar. In the Preferences submenus, select Appearance & Behavior | System Settings | Android SDK. Under the SDK Tools tab, ensure that you have some version of Android SDK Build-Tools installed, and install it if isn't installed already.
  2. We'll also need to add the Android SDK location to the system PATH by editing ~/.bash_profile or ~/.bashrc. You can do this by adding the following line:
export PATH=$PATH:/Users/MY_USER_NAME/Library/Android/sdk

Be sure to replace MY_USER_NAME with your system username.

  1. On macOS, you will also need to add platform-tools to your PATH in ~/.bash_profile or ~/.bashrc. You can do this by adding the following line:

PATH=$PATH:/Users/MY_USER_NAME/Library/Android/platform-tools

Be sure to replace MY_USER_NAME with your system username.

If you've never edited a .bash_profile or .bashrc file before, or aren't familiar with PATH, you can get more information on what purpose they serve and how to work with them from the following resources:
  1. If the PATH was correctly updated, the adb command should work in the Terminal. You may have to restart your Terminal for the changes to take effect.
  1. On a fresh install of Android Studio, you'll see a welcome screen. Start a new app to fully open the software. Then, select the AVD Manager from the buttons in the top -right corner of the window, as indicated in the following steps:
  1. Press Create Virtual Device in the opened modal.
  2. Select a device in the Select Hardware screen, and then press Next:
  1. Download one of the system images under the Recommended tab of the System Image screen:
  1. Press Finish on the final screen and Android Studio will create your new virtual device. The device can be run at any time by pressing the play button in the row of buttons in the top-right corner:

To run your app on an Android emulator during development, Expo used to recommend using the excellent third-party emulator Genymotion. As of Expo version 29, however, they now recommend using the official emulator that ships with Android Studio.

You can follow the step-by-step guide provided in the official Expo documentation to ensure that Android Studio is set up to work properly with your Expo development workflow. The guide can be found at https://docs.expo.io/versions/latest/workflow/android-studio-emulator.

This is all the setup you need to get started developing your first React Native app using Expo! There are, however, a few extra steps you'll need to perform for working with pure React Native applications (non-Expo applications). Pure React Native app development will be covered in depth in Chapter 10, App Workflow and Third-Party Plugins. Since this setup process is a little more involved and subject to change, I recommend referring to the official guide. You can find these instructions in the React Native: Getting Started guide, located at https://facebook.github.io/react-native/docs/getting-started.html under the Building Projects with Native Code tab section.

Once Simulator is open, select your desired iOS device via the menu bar: Hardware | Device | [IOS Version] | [ iOS Device ]. When running Expo applications in Simulator in the future, the same device should be used automatically.

The app can be started with the Expo CLI in your Terminal if you run the following command:

 expo start

The command will build your app and open the Expo Developer Tools in your web browser. In the Expo Developer Tools, select Run on iOS Simulator.

You have been reading a chapter from
React Native Cookbook - Second Edition
Published in: Jan 2019
Publisher: Packt
ISBN-13: 9781788991926
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime