如何在 ubuntu 服务器中安装 android SDK

How to Install android SDK in ubuntu server

我在 ubuntu 服务器中有一个 React Native 项目,我想构建一个 android 应用程序用于生产。为此,我首先必须生成 Gradle 包装文件,所以我 运行 在 android 目录

中执行此命令
gradle wrapper --gradle-version <my-gradle-version>

在我 运行 这个命令之后我得到了这个错误

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

我知道如何使用 local.properties 文件中的 sdk.dirANDROID_HOME 环境变量来定义 SDK 位置。

但我的问题是没有安装 SDK

My question is in react native which sdk I need to build an android app for production and how to install it in ubuntu server

试试这个:

下载最新的android sdk

cd /opt

wget http://dl.google.com/android/android-sdk_r24.4.1-linux.tgz

tar -xvf android-sdk*-linux.tgz

cd android-sdk-linux/tools

./android update sdk --no-ui --filter platform,platform-tools

设置路径

echo 'export PATH=$PATH:/opt/android-sdk-linux/platform-tools' >> /etc/profile.d/android.sh

echo 'export ANDROID_TOOLS=/opt/android-sdk-linux' >> /etc/profile.d/android.sh
source /etc/profile.d/android.sh

添加 i386 支持

dpkg --add-architecture i386

apt-get update

apt-get install -y libc6:i386 libstdc++6:i386 zlib1g:i386

安装sdks

cd /opt/android-sdk-linux/tools

./android list sdk --all

./android update sdk --no-ui --all