Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import react native project in android studio

Tags:

I started development of the android application using atom text editor. It is working fine as long I am writing code in JS and JSX.

I have to do functionality which is not available in react native, so I need to write java code as like https://facebook.github.io/react-native/docs/native-modules-android.html

ToastModule.java

package com.facebook.react.modules.toast;  import android.widget.Toast;  import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod;  import java.util.Map;  public class ToastModule extends ReactContextBaseJavaModule {    private static final String DURATION_SHORT_KEY = "SHORT";   private static final String DURATION_LONG_KEY = "LONG";    public ToastModule(ReactApplicationContext reactContext) {     super(reactContext);   } } 

I do not want to code Java in atom as suggestions are not working. Can we import our react native project in android studio where all in built classes of react native are available so I can have suggestion of classes/methods while writing code.

Is there any way to do this ?

like image 411
N Sharma Avatar asked Apr 26 '17 05:04

N Sharma


People also ask

Can I open React Native in Android Studio?

You will need Node, Watchman, the React Native command line interface, a JDK, and 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.


2 Answers

Go to Android Studio--> then open the Android folder of your RN project

If you want code suggestions, Android Studio will help you while typing ;)

like image 143
hansfpc Avatar answered Sep 21 '22 19:09

hansfpc


Yes, just open android studio. Then Open an existing Android Studio project, select android folder of your react native project.

like image 28
Meysam Izadmehr Avatar answered Sep 19 '22 19:09

Meysam Izadmehr