Mac 安装 Android commandlinetools 各种报错的问题

commandlinetools-mac 下载地址

解压后直接运行 sdkmanager 各种报错:

$ ./sdkmanager --update
Warning: Could not create settings
java.lang.IllegalArgumentException
	at com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings.<init>(SdkManagerCliSettings.java:428)
	at com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings.createSettings(SdkManagerCliSettings.java:152)
	at com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings.createSettings(SdkManagerCliSettings.java:134)
	at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:57)
	at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)

解决

  1. 设置首选ANDROID_HOME
  2. 将commandlinetools zip文件下载并解压缩到名为的目录中cmdline-tools,该目录位于内部ANDROID_HOME
  3. 将目录追加$ANDROID_HOME/cmdline-tools/tools/bin到环境变量PATH,以便系统知道在哪里查找sdkmanager
$ mkdir -p ~/Library/Android/cmdline-tools
$ mv tools ~/Library/Android/cmdline-tools/ # 把解压出来的 tools 移到 cmdline-tools 下面
$ ANDROID_HOME=~/Library/Android
$ ~/Library/Android/cmdline-tools/tools/bin/sdkmanager --version
4.0.1

然后打开 .bash_profile 设置 ANDROID_HOME 和 PATH

export ANDROID_HOME=~/Library/Android
export PATH=\(PATH:\)ANDROID_HOME/cmdline-tools/tools/bin

然后

$ source ~/.bash_profile
$ sdkmanager --version
4.0.1
$

done!

参考链接:https://qastack.cn/programming/60440509/android-command-line-tools-sdkmanager-always-shows-warning-could-not-create-se

Mac 安装 Android commandlinetools 各种报错的问题

上一篇:uniapp实现支付功能


下一篇:uniapp之 页面滑动 组件