在现有的React Native iOS项目中安装React-Native Android?

时间:2022-06-03 15:31:54

I have a fairly involved React-Native project in iOS and want to port it over to Android and test it's transferability. I have done the standard install instructions of:

我在iOS中有一个相当复杂的React-Native项目,并希望将其移植到Android并测试它的可转移性。我已完成以下标准安装说明:

'Install the latest JDK Install the Android SDK: On Mac: brew install android-sdk export ANDROID_HOME=/usr/local/opt/android-sdk Open the Android SDK Manager (on Mac start a new shell and run android); in the window that appears make sure you check: Android SDK Build-tools version 23.0.1 Android 6.0 (API 23) Android Support Repository Click "Install Packages"'

'安装最新的JDK安装Android SDK:在Mac上:brew安装android-sdk导出ANDROID_HOME = / usr / local / opt / android-sdk打开Android SDK Manager(在Mac上启动一个新的shell并运行android);在出现的窗口中确保您检查:Android SDK Build-tools版本23.0.1 Android 6.0(API 23)Android支持存储库单击“安装包”

But I still do not see the Andriod directories in my existing app. Is there a way to get Android dependencies without doing 'react-native init AwesomeProj'?

但我仍然没有在我现有的应用程序中看到Andriod目录。有没有办法获得Android依赖,而不做'react-native init AwesomeProj'?

1 个解决方案

#1


2  

Adding Android to an existing React Native project

If you already have a (iOS-only) React Native project and want to add Android support, you need to execute the following commands in your existing project directory:

如果您已经拥有(仅限iOS)React Native项目并且想要添加Android支持,则需要在现有项目目录中执行以下命令:

Update the react-native dependency in your package.json file to the latest version

将package.json文件中的react-native依赖项更新为最新版本

$ npm install
$ react-native android

#1


2  

Adding Android to an existing React Native project

If you already have a (iOS-only) React Native project and want to add Android support, you need to execute the following commands in your existing project directory:

如果您已经拥有(仅限iOS)React Native项目并且想要添加Android支持,则需要在现有项目目录中执行以下命令:

Update the react-native dependency in your package.json file to the latest version

将package.json文件中的react-native依赖项更新为最新版本

$ npm install
$ react-native android