android - 在 Ubuntu 20.04 中安装没有 Android Studio 的 android sdk
问题描述
以下是我如何安装我的 android sdk 以在我的 Android 手机上运行 React Native:考虑到 Java 和 adb 已经安装:
sudo apt update && sudo apt install android-sdk
这将添加环境变量:
echo 'export ANDROID_HOME="/usr/lib/android-sdk"
export ANDROID_SDK_ROOT="/usr/lib/android-sdk"
PATH=$PATH:$ANDROID_HOME/tools
PATH=$PATH:$ANDROID_HOME/platform-tools
' >> ~/.bashrc
我们现在需要安装缺少的 sdkManager:
source ~/.bashrc
# Download the archive
wget https://dl.google.com/android/repository/commandlinetools-linux-6609375_latest.zip
unzip commandlinetools-linux-6609375_latest.zip -d cmdline-tools
# Make the sdk directory writable
sudo chmod -R a+rw $ANDROID_HOME
# Merge bin with bin and tools with tools
mv cmdline-tools/tools/bin/* $ANDROID_HOME/tools/bin/
rm -rf cmdline-tools/tools/bin
mv cmdline-tools/tools/* $ANDROID_HOME/tools/
rm -rf cmdline-tools
# Accept the licences
yes | $ANDROID_HOME/tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} --licenses
现在,这是我在运行时得到的react-native run-android
:
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:installDebug'.
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '/xxx/android/local.properties'.
好的,我可以在 local.properties 中设置 sdk.dir 并且这很有效,但我不想在我必须处理的每个项目中都这样做。为什么ANDROID_SDK_ROOT
被忽视?
解决方案
推荐阅读
- python - Iterating Through List of Strings, Find Keywords and Print
- angular - Angular:如何重置 matChipList 输入字段和 Google Recaptcha?
- symfony - 未添加 Symfony Http 客户端默认标头
- image - 为什么放大+缩小时图标会被更改/破坏?
- javascript - 如何将 JS 变量值设置为 Odoo qweb 模板变量值
- c++ - 循环无限运行 C++ 以解决骑士巡回赛问题
- reactjs - 反应useState不更新值
- c++ - 错误没有重载函数“getline”的实例与参数列表匹配
- audio - 如何使用ffmpeg更改mp4文件的h264属性、yuv、fps、tbr、tbn、tbc?
- python - 在python中将字符串转换为多维列表