Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set up Android for React-Native without Android Studio but only using the SDK tools?

I've read pretty much read every article from google search, watched all the YouTube tutorials and checked out all the StackOverflow questions relating to this but cannot find my answer.

The official (but outdated) docs is not all that useful at all.
https://facebook.github.io/react-native/releases/0.23/docs/android-setup.html
http://facebook.github.io/react-native/releases/0.40/docs/getting-started.html

I am using Windows 10.

So far I have,


User Variables:

PATH
C:\Users\RickyDam\AppData\Local\Android\android-sdk\tools
C:\Users\RickyDam\AppData\Local\Android\android-sdk\platform-tools


System Variables:

ANDROID_HOME
C:\Users\RickyDam\AppData\Local\Android\android-sdk

ANDROID_SDK_HOME
C:\Users\RickyDam\AppData\Local\Android\android-sdk

JAVA_HOME
C:\Program Files\Java\jdk1.8.0_144

PATH
C:\Users\RickyDam\AppData\Local\Android\android-sdk\tools
C:\Users\RickyDam\AppData\Local\Android\android-sdk\platform-tools


My git bash just keeps showing

bash: android: command not found

And if I try to type in android.bat, it returns

The "android" command is deprecated.
For manual SDK, AVD, and project management, please use Android Studio.
For command-line tools, use tools\bin\sdkmanager.bat
and tools\bin\avdmanager.bat

And then if I try to type in sdkmanager.bat, I get

bash: sdkmanager.bat: command not found

EDIT:
I found out about the official SDK Manager installer made by Google Inc. and now my folder C:\Users\RickyDam\AppData\Local\Android\android-sdk looks like this

screenshot of android-sdk folder

But I still get

android: command not found

even though my environment variables seem to all be in place...

like image 770
Ricky Dam Avatar asked Aug 11 '17 03:08

Ricky Dam


People also ask

Can I use React Native without Android Studio?

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.

Can I get Android SDK without Android Studio?

You will need to download the Android SDK without Android Studio bundled. Go to Android SDK and navigate to the SDK Tools Only section. Copy the URL for the download that's appropriate for your build machine OS. Unzip and place the contents within your home directory.

Can we use Android SDK in React Native?

React Native requires Android 6.0 (Marshmallow) SDK or later. We recommend using the latest SDK. Create environment variable paths for the Java SDK and Android SDK: In the Windows search menu, enter: "Edit the system environment variables", this will open the System Properties window.


1 Answers

Windows 10

  1. Install Java SE Development Kit 8
    http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

  2. Install Android SDK Manager
    http://filehippo.com/download_android_sdk/

  3. Install the options that are already selected when you open the SDK Manager
    Android SDK Tools
    Android SDK Platform-tools
    Android SDK Build-tools
    Android 8.0.0 (API 26)
    Extras > Google USB Driver

  4. Navigate to Control Panel \ System and Security \ System \ Advanced System Settings \ Environment Variables

  5. For User Variables select Path and click Edit....

  6. Click New and add these:
    C:\Users\PC-NAME\AppData\Local\Android\android-sdk\tools
    C:\Users\PC-NAME\AppData\Local\Android\android-sdk\platform-tools
    C:\Program Files\Java\jdk1.8.0_144

Now to confirm that it works, open cmd and type in android, the Android SDK Manager should open up.

NOTE: I suggest using the default command prompt over a third party one such as Git Bash. With cmd, when you run commands such as npm install, you actually get a loading bar where as in Git bash, you don't get one. Some commands that work properly in cmd such as android will not be recognized by Git bash.

  1. Now in the command prompt, cd to the Desktop.

  2. Run these commands:
    npm install -g create-react-native-app
    create-react-native-app my-app
    cd my-app/
    npm start

like image 181
Ricky Dam Avatar answered Oct 14 '22 05:10

Ricky Dam