How to import react native project in android studio

39,480

Solution 1

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 ;)

Solution 2

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

Share:
39,480

Related videos on Youtube

N Sharma
Author by

N Sharma

I have done masters in Advanced Software Engineering. I have worked on various technologies like Java, Android, Design patterns. My research area during my masters is revolving around the Recommendation algorithms that E-commerce websites are using in order to recommend the products to their customers on the basis of their preferences.

Updated on July 09, 2022

Comments

  • N Sharma
    N Sharma almost 2 years

    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 ?

  • HomeMade
    HomeMade over 6 years
    If it is react native built using npm, and it is not template of Android studio project, will it work fine? What is the import project option then?
  • Ajay Mistry
    Ajay Mistry almost 6 years
    no such file or directory ...have no directory... /android/src in react native project
  • hansfpc
    hansfpc almost 6 years
    @AjayMistry, you must've created a project using "react-native-cli", not Expo. Expo projects does not have a "android" folder
  • Ajay Mistry
    Ajay Mistry almost 6 years
    there is android folder but in that i cant find that src folder
  • Ankit Jayaprakash
    Ankit Jayaprakash almost 5 years
    Can we run android Module from android studio. Suppose in this toast example how can we test the duration is short or long using android studio ? Do we need to run the react native app?
  • nikel
    nikel over 4 years
    I had to do a forceSync from ResourceManager to let androidStudio set the project up . It didn't do it by default.
  • Abhinav Saxena
    Abhinav Saxena over 4 years
    When I try to run the project from AndroidStudio, it says : "reactnative" not found on the build console.
  • subparry
    subparry about 2 years
    Great! this solved it. Thanks!
  • famfamfam
    famfamfam about 2 years
    what i need to do if i want to my react project can be done for IOS?
  • hansfpc
    hansfpc about 2 years
    the process is very similar but in XCode, just import the ios folder @famfamfam