简体   繁体   English

如何导入在android studio中反应原生项目

[英]How to import react native project in android studio

I started development of the android application using atom text editor. 我开始使用atom文本编辑器开发android应用程序。 It is working fine as long I am writing code in JS and JSX. 我在JS和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 我必须做反应原生的功能,所以我需要编写java代码,如https://facebook.github.io/react-native/docs/native-modules-android.html

ToastModule.java 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. 我不想在atom编写Java代码,因为建议不起作用。 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. 我们可以在android studio中导入我们的react本机项目,其中所有内置的react本机类都可用,因此我可以在编写代码时提供类/方法的建议。

Is there any way to do this ? 有没有办法做到这一点?

Go to Android Studio--> then open the Android folder of your RN project 转到Android Studio - >然后打开RN项目的Android文件夹

If you want code suggestions, Android Studio will help you while typing ;) 如果您需要代码建议,Android Studio会在打字时帮助您;)

Yes, just open android studio. 是的,只需打开android studio。 Then Open an existing Android Studio project , select android folder of your react native project. 然后打开现有的Android Studio项目 ,选择您的反应原生项目的android文件夹。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM