mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
47 lines
32 KiB
HTML
47 lines
32 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
<meta name="generator" content="Docusaurus v2.0.0-alpha.66">
|
|
<link rel="alternate" type="application/rss+xml" href="/blog/rss.xml" title="React Native Blog RSS Feed">
|
|
<link rel="alternate" type="application/atom+xml" href="/blog/atom.xml" title="React Native Blog Atom Feed">
|
|
<link rel="preconnect" href="https://www.google-analytics.com">
|
|
<script>window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)},ga.l=+new Date,ga("create","UA-41298772-2","auto"),ga("send","pageview")</script>
|
|
<script async src="https://www.google-analytics.com/analytics.js"></script>
|
|
<link rel="preconnect" href="https://www.google-analytics.com">
|
|
<link rel="preconnect" href="https://www.googletagmanager.com">
|
|
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-41298772-2"></script>
|
|
<script>function gtag(){dataLayer.push(arguments)}window.dataLayer=window.dataLayer||[],gtag("js",new Date),gtag("config","UA-41298772-2",{})</script>
|
|
<link rel="search" type="application/opensearchdescription+xml" title="React Native" href="/opensearch.xml">
|
|
<script src="https://cdn.jsdelivr.net/npm/focus-visible@5.2.0/dist/focus-visible.min.js" defer="defer"></script>
|
|
<script src="https://snack.expo.io/embed.js" defer="defer"></script><title data-react-helmet="true">_getting-started-linux-android · React Native</title><meta data-react-helmet="true" property="twitter:image" content="https://reactnative.dev/img/logo-og.png"><meta data-react-helmet="true" name="twitter:image:alt" content="Image for React Native"><meta data-react-helmet="true" name="docsearch:language" content="en"><meta data-react-helmet="true" name="docsearch:version" content="0.62"><meta data-react-helmet="true" name="docsearch:docusaurus_tag" content="docs-default-0.62"><meta data-react-helmet="true" property="og:image" content="https://reactnative.dev/img/logo-og.png"><meta data-react-helmet="true" name="twitter:card" content="summary"><meta data-react-helmet="true" name="twitter:image" content="https://reactnative.dev/img/logo-og.png"><meta data-react-helmet="true" property="og:title" content="_getting-started-linux-android · React Native"><meta data-react-helmet="true" name="description" content="Installing dependencies"><meta data-react-helmet="true" property="og:description" content="Installing dependencies"><meta data-react-helmet="true" property="og:url" content="https://reactnative.dev/docs/0.62/_getting-started-linux-android"><link data-react-helmet="true" rel="shortcut icon" href="/img/favicon.ico"><link data-react-helmet="true" rel="preconnect" href="https://BH4D9OD16A-dsn.algolia.net" crossorigin="anonymous"><link data-react-helmet="true" rel="canonical" href="https://reactnative.dev/docs/0.62/_getting-started-linux-android"><link rel="stylesheet" href="/styles.fccefeba.css">
|
|
<link rel="stylesheet" href="/main.ca40cabd.css">
|
|
<link rel="preload" href="/styles.07d522c6.js" as="script">
|
|
<link rel="preload" href="/runtime~main.3fb4c035.js" as="script">
|
|
<link rel="preload" href="/main.5a3c9855.js" as="script">
|
|
<link rel="preload" href="/1.ba9ce8bd.js" as="script">
|
|
<link rel="preload" href="/2.58cb5d3d.js" as="script">
|
|
<link rel="preload" href="/1f391b9e.a824c215.js" as="script">
|
|
<link rel="preload" href="/943.8b024446.js" as="script">
|
|
<link rel="preload" href="/3225cd47.eb6210e6.js" as="script">
|
|
<link rel="preload" href="/17896441.0c201679.js" as="script">
|
|
<link rel="preload" href="/c6324ea2.bdb87aa9.js" as="script">
|
|
<link rel="preload" href="/dd977e17.ba60f6b4.js" as="script">
|
|
</head>
|
|
<body>
|
|
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"light")}()</script><div id="__docusaurus">
|
|
<nav class="navbar navbar--fixed-top navbar--dark"><div class="navbar__inner"><div class="navbar__items"><div aria-label="Navigation bar toggle" class="navbar__toggle" role="button" tabindex="0"><svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 30 30" role="img" focusable="false"><title>Menu</title><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></div><a class="navbar__brand" href="/"><img class="navbar__logo" src="/img/header_logo.svg" alt="React Native"><strong class="navbar__title">React Native</strong></a><div class="navbar__item dropdown dropdown--hoverable dropdown--left"><a class="navbar__item navbar__link" href="/docs/0.62/getting-started">0.62</a><ul class="dropdown__menu"><li><a class="dropdown__link" href="/docs/next/_getting-started-linux-android">Next</a></li><li><a class="dropdown__link" href="/docs/_getting-started-linux-android">0.63</a></li><li><a aria-current="page" class="dropdown__link dropdown__link--active" href="/docs/0.62/_getting-started-linux-android">0.62</a></li><li><a class="dropdown__link" href="/docs/0.61/_getting-started-linux-android">0.61</a></li><li><a class="dropdown__link" href="/docs/0.60/_getting-started-linux-android">0.60</a></li><li><a class="dropdown__link" href="/versions">All versions</a></li></ul></div></div><div class="navbar__items navbar__items--right"><a class="navbar__item navbar__link" href="/docs/0.62/getting-started">Docs</a><a class="navbar__item navbar__link" href="/docs/0.62/components-and-apis">Components</a><a class="navbar__item navbar__link" href="/docs/0.62/accessibilityinfo">API</a><a class="navbar__item navbar__link" href="/help">Community</a><a class="navbar__item navbar__link" href="/blog">Blog</a><a href="https://github.com/facebook/react-native" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link navbar-github-link" aria-label="GitHub repository"></a><div class="react-toggle react-toggle--disabled displayOnlyInLargeViewport_3lWe"><div class="react-toggle-track"><div class="react-toggle-track-check"><span class="toggle_gnXW">🌜</span></div><div class="react-toggle-track-x"><span class="toggle_gnXW">🌞</span></div></div><div class="react-toggle-thumb"></div><input type="checkbox" disabled="" aria-label="Dark mode toggle" class="react-toggle-screenreader-only"></div><button type="button" class="DocSearch DocSearch-Button" aria-label="Search"><svg width="20" height="20" class="DocSearch-Search-Icon" viewBox="0 0 20 20"><path d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"></path></svg><span class="DocSearch-Button-Placeholder">Search</span><span class="DocSearch-Button-Key">⌘</span><span class="DocSearch-Button-Key">K</span></button></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div><div class="navbar-sidebar"><div class="navbar-sidebar__brand"><a class="navbar__brand" href="/"><img class="navbar__logo" src="/img/header_logo.svg" alt="React Native"><strong class="navbar__title">React Native</strong></a></div><div class="navbar-sidebar__items"><div class="menu"><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" href="/docs/0.62/getting-started">Docs</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/0.62/components-and-apis">Components</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/0.62/accessibilityinfo">API</a></li><li class="menu__list-item"><a class="menu__link" href="/help">Community</a></li><li class="menu__list-item"><a class="menu__link" href="/blog">Blog</a></li><li class="menu__list-item"><a role="button" class="menu__link menu__link--sublist">Versions</a><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" href="/docs/next/_getting-started-linux-android">Next</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/_getting-started-linux-android">0.63</a></li><li class="menu__list-item"><a aria-current="page" class="menu__link menu__link--active" href="/docs/0.62/_getting-started-linux-android">0.62</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/0.61/_getting-started-linux-android">0.61</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/0.60/_getting-started-linux-android">0.60</a></li><li class="menu__list-item"><a class="menu__link" href="/versions">All versions</a></li></ul></li><li class="menu__list-item"><a href="https://github.com/facebook/react-native" target="_blank" rel="noopener noreferrer" class="menu__link navbar-github-link" aria-label="GitHub repository"></a></li></ul></div></div></div></nav><div class="main-wrapper"><div class="docPage_2UBv"><main class="docMainContainer_1rYT"><div class="container padding-vert--lg docItemWrapper_1Hme"><div class="row"><div class="col docItemCol_2AGf"><div class="alert alert--warning margin-bottom--md" role="alert"><div>This is documentation for React Native <strong>0.62</strong>, which is no longer actively maintained.</div><div class="margin-top--md">For up-to-date documentation, see the <strong><a href="/docs/_getting-started-linux-android">latest version</a></strong> (0.63).</div></div><div class="docItemContainer_1tAC"><article><div><span class="badge badge--secondary">Version: 0.62</span></div><header><h1 class="docTitle_cWlf">_getting-started-linux-android</h1></header><div class="markdown"><h2><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="installing-dependencies"></a>Installing dependencies<a aria-hidden="true" tabindex="-1" class="hash-link" href="#installing-dependencies" title="Direct link to heading">#</a></h2><p>You will need Node, the React Native command line interface, a JDK, and Android Studio.</p><p>While you can use any editor of your choice to develop your app, you will need to install Android Studio in order to set up the necessary tooling to build your React Native app for Android.</p><h3>Node</h3><p>Follow the <a href="https://nodejs.org/en/download/package-manager/" target="_blank" rel="noopener noreferrer">installation instructions for your Linux distribution</a> to install Node 10 or newer.</p><h3>Java Development Kit</h3><p>React Native requires at least the version 8 of the Java SE Development Kit (JDK). You may download and install <a href="http://openjdk.java.net" target="_blank" rel="noopener noreferrer">OpenJDK</a> from <a href="https://adoptopenjdk.net/" target="_blank" rel="noopener noreferrer">AdoptOpenJDK</a> or your system packager. You may also <a href="https://www.oracle.com/java/technologies/javase-jdk14-downloads.html" target="_blank" rel="noopener noreferrer">Download and install Oracle JDK 14</a> if desired.</p><h3>Android development environment</h3><p>Setting up your development environment can be somewhat tedious if you're new to Android development. If you're already familiar with Android development, there are a few things you may need to configure. In either case, please make sure to carefully follow the next few steps.</p><h4>1. Install Android Studio</h4><p><a href="https://developer.android.com/studio/index.html" target="_blank" rel="noopener noreferrer">Download and install Android Studio</a>. While on Android Studio installation wizard, make sure the boxes next to all of the following items are checked:</p><ul><li><code>Android SDK</code></li><li><code>Android SDK Platform</code></li><li><code>Android Virtual Device</code></li></ul><p>Then, click "Next" to install all of these components.</p><blockquote><p>If the checkboxes are grayed out, you will have a chance to install these components later on.</p></blockquote><p>Once setup has finalized and you're presented with the Welcome screen, proceed to the next step.</p><h4>2. Install the Android SDK</h4><p>Android Studio installs the latest Android SDK by default. Building a React Native app with native code, however, requires the <code>Android 10 (Q)</code> SDK in particular. Additional Android SDKs can be installed through the SDK Manager in Android Studio.</p><p>To do that, open Android Studio, click on "Configure" button and select "SDK Manager".</p><blockquote><p>The SDK Manager can also be found within the Android Studio "Preferences" dialog, under <strong>Appearance & Behavior</strong> → <strong>System Settings</strong> → <strong>Android SDK</strong>.</p></blockquote><p>Select the "SDK Platforms" tab from within the SDK Manager, then check the box next to "Show Package Details" in the bottom right corner. Look for and expand the <code>Android 10 (Q)</code> entry, then make sure the following items are checked:</p><ul><li><code>Android SDK Platform 29</code></li><li><code>Intel x86 Atom_64 System Image</code> or <code>Google APIs Intel x86 Atom System Image</code></li></ul><p>Next, select the "SDK Tools" tab and check the box next to "Show Package Details" here as well. Look for and expand the "Android SDK Build-Tools" entry, then make sure that <code>29.0.2</code> is selected.</p><p>Finally, click "Apply" to download and install the Android SDK and related build tools.</p><h4>3. Configure the ANDROID_HOME environment variable</h4><p>The React Native tools require some environment variables to be set up in order to build apps with native code.</p><p>Add the following lines to your <code>$HOME/.bash_profile</code> or <code>$HOME/.bashrc</code> (if you are using <code>zsh</code> then <code>~/.zprofile</code> or <code>~/.zshrc</code>) config file:</p><div class="mdxCodeBlock_xYIz"><div class="codeBlockContent_rlEb"><button tabindex="0" type="button" aria-label="Copy code to clipboard" class="copyButton_kOW4">Copy</button><div class="prism-code language-shell codeBlock_1AP7"><div class="codeBlockLines_1boI" style="color:#FFFFFF;background:#282C34"><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token builtin class-name" style="color:#fac863">export</span><span class="token plain"> </span><span class="token assign-left variable" style="color:#cb4b16">ANDROID_HOME</span><span class="token operator" style="color:#fc929e">=</span><span class="token environment constant" style="color:#5a9bcf">$HOME</span><span class="token plain">/Android/Sdk</span></div><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain"></span><span class="token builtin class-name" style="color:#fac863">export</span><span class="token plain"> </span><span class="token assign-left variable environment constant" style="color:#5a9bcf">PATH</span><span class="token operator" style="color:#fc929e">=</span><span class="token environment constant" style="color:#5a9bcf">$PATH</span><span class="token builtin class-name" style="color:#fac863">:</span><span class="token variable" style="color:#cb4b16">$ANDROID_HOME</span><span class="token plain">/emulator</span></div><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain"></span><span class="token builtin class-name" style="color:#fac863">export</span><span class="token plain"> </span><span class="token assign-left variable environment constant" style="color:#5a9bcf">PATH</span><span class="token operator" style="color:#fc929e">=</span><span class="token environment constant" style="color:#5a9bcf">$PATH</span><span class="token builtin class-name" style="color:#fac863">:</span><span class="token variable" style="color:#cb4b16">$ANDROID_HOME</span><span class="token plain">/tools</span></div><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain"></span><span class="token builtin class-name" style="color:#fac863">export</span><span class="token plain"> </span><span class="token assign-left variable environment constant" style="color:#5a9bcf">PATH</span><span class="token operator" style="color:#fc929e">=</span><span class="token environment constant" style="color:#5a9bcf">$PATH</span><span class="token builtin class-name" style="color:#fac863">:</span><span class="token variable" style="color:#cb4b16">$ANDROID_HOME</span><span class="token plain">/tools/bin</span></div><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain"></span><span class="token builtin class-name" style="color:#fac863">export</span><span class="token plain"> </span><span class="token assign-left variable environment constant" style="color:#5a9bcf">PATH</span><span class="token operator" style="color:#fc929e">=</span><span class="token environment constant" style="color:#5a9bcf">$PATH</span><span class="token builtin class-name" style="color:#fac863">:</span><span class="token variable" style="color:#cb4b16">$ANDROID_HOME</span><span class="token plain">/platform-tools</span></div></div></div></div></div><blockquote><p><code>.bash_profile</code> is specific to <code>bash</code>. If you're using another shell, you will need to edit the appropriate shell-specific config file.</p></blockquote><p>Type <code>source $HOME/.bash_profile</code> for <code>bash</code> or <code>source $HOME/.zprofile</code> to load the config into your current shell. Verify that ANDROID_HOME has been set by running <code>echo $ANDROID_HOME</code> and the appropriate directories have been added to your path by running <code>echo $PATH</code>.</p><blockquote><p>Please make sure you use the correct Android SDK path. You can find the actual location of the SDK in the Android Studio "Preferences" dialog, under <strong>Appearance & Behavior</strong> → <strong>System Settings</strong> → <strong>Android SDK</strong>.</p></blockquote><h3>Watchman</h3><p>Follow the <a href="https://facebook.github.io/watchman/docs/install/#buildinstall" target="_blank" rel="noopener noreferrer">Watchman installation guide</a> to compile and install Watchman from source.</p><blockquote><p><a href="https://facebook.github.io/watchman/docs/install/" target="_blank" rel="noopener noreferrer">Watchman</a> is a tool by Facebook for watching changes in the filesystem. It is highly recommended you install it for better performance and increased compatibility in certain edge cases (translation: you may be able to get by without installing this, but your mileage may vary; installing this now may save you from a headache later).</p></blockquote><h3>React Native Command Line Interface</h3><p>React Native has a built-in command line interface. Rather than install and manage a specific version of the CLI globally, we recommend you access the current version at runtime using <code>npx</code>, which ships with Node.js. With <code>npx react-native <command></code>, the current stable version of the CLI will be downloaded and executed at the time the command is run.</p><h2>Creating a new application</h2><blockquote><p>If you previously installed a global <code>react-native-cli</code> package, please remove it as it may cause unexpected issues.</p></blockquote><p>React Native has a built-in command line interface, which you can use to generate a new project. You can access it without installing anything globally using <code>npx</code>, which ships with Node.js. Let's create a new React Native project called "AwesomeProject":</p><div class="mdxCodeBlock_xYIz"><div class="codeBlockContent_rlEb"><button tabindex="0" type="button" aria-label="Copy code to clipboard" class="copyButton_kOW4">Copy</button><div class="prism-code language-shell codeBlock_1AP7"><div class="codeBlockLines_1boI" style="color:#FFFFFF;background:#282C34"><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain">npx react-native init AwesomeProject</span></div></div></div></div></div><p>This is not necessary if you are integrating React Native into an existing application, if you "ejected" from Expo, or if you're adding Android support to an existing React Native project (see <a href="/docs/0.62/platform-specific-code">Platform Specific Code</a>). You can also use a third-party CLI to init your React Native app, such as <a href="https://github.com/infinitered/ignite" target="_blank" rel="noopener noreferrer">Ignite CLI</a>.</p><h3>[Optional] Using a specific version or template</h3><p>If you want to start a new project with a specific React Native version, you can use the <code>--version</code> argument:</p><div class="mdxCodeBlock_xYIz"><div class="codeBlockContent_rlEb"><button tabindex="0" type="button" aria-label="Copy code to clipboard" class="copyButton_kOW4">Copy</button><div class="prism-code language-shell codeBlock_1AP7"><div class="codeBlockLines_1boI" style="color:#FFFFFF;background:#282C34"><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain">npx react-native init AwesomeProject --version X.XX.X</span></div></div></div></div></div><p>You can also start a project with a custom React Native template, like TypeScript, with <code>--template</code> argument:</p><div class="mdxCodeBlock_xYIz"><div class="codeBlockContent_rlEb"><button tabindex="0" type="button" aria-label="Copy code to clipboard" class="copyButton_kOW4">Copy</button><div class="prism-code language-shell codeBlock_1AP7"><div class="codeBlockLines_1boI" style="color:#FFFFFF;background:#282C34"><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain">npx react-native init AwesomeTSProject --template react-native-template-typescript</span></div></div></div></div></div><h2>Preparing the Android device</h2><p>You will need an Android device to run your React Native Android app. This can be either a physical Android device, or more commonly, you can use an Android Virtual Device which allows you to emulate an Android device on your computer.</p><p>Either way, you will need to prepare the device to run Android apps for development.</p><h3>Using a physical device</h3><p>If you have a physical Android device, you can use it for development in place of an AVD by plugging it in to your computer using a USB cable and following the instructions <a href="/docs/0.62/running-on-device">here</a>.</p><h3>Using a virtual device</h3><p>If you use Android Studio to open <code>./AwesomeProject/android</code>, you can see the list of available Android Virtual Devices (AVDs) by opening the "AVD Manager" from within Android Studio. Look for an icon that looks like this:</p><p><img alt="Android Studio AVD Manager" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAZCAIAAABCYLJOAAACLUlEQVR4Ab2Vw6IfPxiG3zfJHPPP2rbdfW3rProsLqCr7rqsbVur2raPPb+Z5Du2+YyRJ87HtLQ0dAIKnYNBQ5BEI4hI271BEIjUNZAgqbUm2WovyRLpyVMnfd83xggq3ATDMHTOzZo1q3ev3iRbXV4RKZEuXLBQayPOAQSESjlnDx85nJ+fjwpa7zUlaHPj2CO/oLTUNnTR8Wb2kvGeZ9rVbwJxTuArm69haAMaqtJXgnZ5y1tVmxKsMoqgKS0p2z1+WdEgItWXjp4XJEiCHesVZ50LnbUOrcE0LQURk2BsYHU0ASmnuqUgrfaSEAcvWs9eMQbKGe0J0L17j8TERJICW+hnx0Ylk6o17SAVF6U1lL3/bld+UbrAzpgx9f///4sEeT/TH955srMwkk2wNeUlROCsiBNCicu7dH+zH5BUgChapThh0NrYqCRpbTsoxZiEKBu60EbSsr+m5Z7RaoiIJQkQkv3lz8De/8/0tJEWekmKdSXb9MUjRYK7L3bk+996/7PpT/Zr6yIko0xcSsK0r2n33/+4NLjnXNIA0nz7kizy/b379ly6ckGIb+kPUhP7zZu5zTN/B/ZzaL+lxPecN2O7YsKbL2edOLLF5f3/v/+zsrOSk1MAxEb1z8j5dezaVggTYiYDyCnIP359q4gENl4EDdJwfLPWAiCplAptABEHp2oMKSfljzTaa0W/GVPxXkQ8EwWw5gCs+VhCK7w1/25o0ZHOj8dd7C0GRnwgNA5r8rwAAAAASUVORK5CYII="></p><p>If you have recently installed Android Studio, you will likely need to <a href="https://developer.android.com/studio/run/managing-avds.html" target="_blank" rel="noopener noreferrer">create a new AVD</a>. Select "Create Virtual Device...", then pick any Phone from the list and click "Next", then select the <strong>Q</strong> API Level 29 image.</p><blockquote><p>We recommend configuring <a href="https://developer.android.com/studio/run/emulator-acceleration.html#vm-linux" target="_blank" rel="noopener noreferrer">VM acceleration</a> on your system to improve performance. Once you've followed those instructions, go back to the AVD Manager.</p></blockquote><p>Click "Next" then "Finish" to create your AVD. At this point you should be able to click on the green triangle button next to your AVD to launch it, then proceed to the next step.</p><h2>Running your React Native application</h2><h3>Step 1: Start Metro</h3><p>First, you will need to start Metro, the JavaScript bundler that ships with React Native. Metro "takes in an entry file and various options, and returns a single JavaScript file that includes all your code and its dependencies."—<a href="https://facebook.github.io/metro/docs/concepts" target="_blank" rel="noopener noreferrer">Metro Docs</a></p><p>To start Metro, run <code>npx react-native start</code> inside your React Native project folder:</p><div class="mdxCodeBlock_xYIz"><div class="codeBlockContent_rlEb"><button tabindex="0" type="button" aria-label="Copy code to clipboard" class="copyButton_kOW4">Copy</button><div class="prism-code language-shell codeBlock_1AP7"><div class="codeBlockLines_1boI" style="color:#FFFFFF;background:#282C34"><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain">npx react-native start</span></div></div></div></div></div><p><code>react-native start</code> starts Metro Bundler.</p><blockquote><p>If you use the Yarn package manager, you can use <code>yarn</code> instead of <code>npx</code> when running React Native commands inside an existing project.</p></blockquote><blockquote><p>If you're familiar with web development, Metro is a lot like webpack—for React Native apps. Unlike Kotlin or Java, JavaScript isn't compiled—and neither is React Native. Bundling isn't the same as compiling, but it can help improve startup performance and translate some platform-specific JavaScript into more JavaScript.</p></blockquote><h3>Step 2: Start your application</h3><p>Let Metro Bundler run in its own terminal. Open a new terminal inside your React Native project folder. Run the following:</p><div class="mdxCodeBlock_xYIz"><div class="codeBlockContent_rlEb"><button tabindex="0" type="button" aria-label="Copy code to clipboard" class="copyButton_kOW4">Copy</button><div class="prism-code language-shell codeBlock_1AP7"><div class="codeBlockLines_1boI" style="color:#FFFFFF;background:#282C34"><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain">npx react-native run-android</span></div></div></div></div></div><p>If everything is set up correctly, you should see your new app running in your Android emulator shortly.</p><p><code>npx react-native run-android</code> is one way to run your app - you can also run it directly from within Android Studio.</p><blockquote><p>If you can't get this to work, see the <a href="/docs/0.62/troubleshooting#content">Troubleshooting</a> page.</p></blockquote><h3>Modifying your app</h3><p>Now that you have successfully run the app, let's modify it.</p><ul><li>Open <code>App.js</code> in your text editor of choice and edit some lines.</li><li>Press the <code>R</code> key twice or select <code>Reload</code> from the Developer Menu (<code>Ctrl + M</code>) to see your changes!</li></ul><h3>That's it!</h3><p>Congratulations! You've successfully run and modified your first React Native app.</p><center><img src="/docs/assets/GettingStartedCongratulations.png" width="150"></center><h2>Now what?</h2><ul><li>If you want to add this new React Native code to an existing application, check out the <a href="/docs/0.62/integration-with-existing-apps">Integration guide</a>.</li></ul><p>If you're curious to learn more about React Native, check out the <a href="/docs/0.62/getting-started">Introduction to React Native</a>.</p></div></article><div class="docMetadata margin-vert--xl"><div class="row"><div class="col"><a href="https://github.com/facebook/react-native-website/blob/master/website/versioned_docs/version-0.62/_getting-started-linux-android.md" target="_blank" rel="noreferrer noopener"><svg fill="currentColor" height="1.2em" width="1.2em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 40 40" style="margin-right:0.3em;vertical-align:sub"><g><path d="m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z"></path></g></svg>Edit this page</a></div><div class="col text--right"><em><small class="docMetadata-updated">Last updated on <time datetime="2020-12-02T00:14:52.000Z" class="docLastUpdatedAt_1gIo">12/2/2020</time></small></em></div></div></div><div class="margin-vert--lg"><nav class="pagination-nav" aria-label="Blog list page navigation"><div class="pagination-nav__item"></div><div class="pagination-nav__item pagination-nav__item--next"></div></nav></div></div></div><div class="col col--3"><div class="tableOfContents_3iuQ"><ul class="table-of-contents table-of-contents__left-border"><li><a href="#installing-dependencies" class="table-of-contents__link">Installing dependencies</a></li></ul></div></div></div></div></main></div></div><footer class="footer footer--dark"><div class="container"><div class="row footer__links"><div class="col footer__col"><h4 class="footer__title">Docs</h4><ul class="footer__items"><li class="footer__item"><a class="footer__link-item" href="/docs/getting-started">Getting Started</a></li><li class="footer__item"><a class="footer__link-item" href="/docs/tutorial">Tutorial</a></li><li class="footer__item"><a class="footer__link-item" href="/docs/components-and-apis">Components and APIs</a></li><li class="footer__item"><a class="footer__link-item" href="/docs/more-resources">More Resources</a></li></ul></div><div class="col footer__col"><h4 class="footer__title">Community</h4><ul class="footer__items"><li class="footer__item"><a class="footer__link-item" href="/help">The React Native Community</a></li><li class="footer__item"><a class="footer__link-item" href="/showcase">Who's using React Native?</a></li><li class="footer__item"><a href="https://stackoverflow.com/questions/tagged/react-native" target="_blank" rel="noopener noreferrer" class="footer__link-item">Ask Questions on Stack Overflow</a></li><li class="footer__item"><a href="https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md" target="_blank" rel="noopener noreferrer" class="footer__link-item">Contributor Guide</a></li><li class="footer__item"><a href="https://dev.to/t/reactnative" target="_blank" rel="noopener noreferrer" class="footer__link-item">DEV Community</a></li></ul></div><div class="col footer__col"><h4 class="footer__title">Find us</h4><ul class="footer__items"><li class="footer__item"><a class="footer__link-item" href="/blog">Blog</a></li><li class="footer__item"><a href="https://twitter.com/reactnative" target="_blank" rel="noopener noreferrer" class="footer__link-item">Twitter</a></li><li class="footer__item"><a href="https://github.com/facebook/react-native" target="_blank" rel="noopener noreferrer" class="footer__link-item">GitHub</a></li></ul></div><div class="col footer__col"><h4 class="footer__title">More</h4><ul class="footer__items"><li class="footer__item"><a href="https://reactjs.org/" target="_blank" rel="noopener noreferrer" class="footer__link-item">React</a></li><li class="footer__item"><a href="https://opensource.facebook.com/legal/privacy" target="_blank" rel="noopener noreferrer" class="footer__link-item">Privacy Policy</a></li><li class="footer__item"><a href="https://opensource.facebook.com/legal/terms" target="_blank" rel="noopener noreferrer" class="footer__link-item">Terms of Service</a></li></ul></div></div><div class="text--center"><div class="margin-bottom--sm"><a href="https://opensource.facebook.com" target="_blank" rel="noopener noreferrer" class="footerLogoLink_19Ac"><img class="footer__logo" alt="Facebook Open Source Logo" src="/img/oss_logo.png"></a></div><div>Copyright © 2020 Facebook, Inc.</div></div></div></footer></div>
|
|
<script src="/styles.07d522c6.js"></script>
|
|
<script src="/runtime~main.3fb4c035.js"></script>
|
|
<script src="/main.5a3c9855.js"></script>
|
|
<script src="/1.ba9ce8bd.js"></script>
|
|
<script src="/2.58cb5d3d.js"></script>
|
|
<script src="/1f391b9e.a824c215.js"></script>
|
|
<script src="/943.8b024446.js"></script>
|
|
<script src="/3225cd47.eb6210e6.js"></script>
|
|
<script src="/17896441.0c201679.js"></script>
|
|
<script src="/c6324ea2.bdb87aa9.js"></script>
|
|
<script src="/dd977e17.ba60f6b4.js"></script>
|
|
</body>
|
|
</html> |