Android命令行工具sdkmanager始终显示:警告:无法创建设置 [英] Android Command line tools sdkmanager always shows: Warning: Could not create settings
问题描述
我使用了android的新命令行工具,因为android的旧sdk-tools存储库不再可用.因此,我更改了gitlab-ci以加载commandlintools.但是,当我尝试运行它时,出现以下错误:
I use the new Command line tools of android because the old sdk-tools repository of android isn't available anymore. So I changed my gitlab-ci to load the commandlintools. But when I try to run it I get the following error:
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)
我已经尝试过手动执行那些命令,但遇到相同的错误.另外,如果我运行sdkmanager --version
,也会发生相同的错误.
我的gitlab-ci看起来像:
I already tried executing those commandy by hand, but I get the same error. Also if i run sdkmanager --version
, the same error occurs.
My gitlab-ci looks like:
image: openjdk:9-jdk
variables:
ANDROID_COMPILE_SDK: "29"
ANDROID_BUILD_TOOLS: "29.0.3"
ANDROID_SDK_TOOLS: "6200805"
before_script:
- apt-get --quiet update --yes
- apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1
- wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS}_latest.zip
- unzip -d android-sdk-linux android-sdk.zip
- echo y | android-sdk-linux/tools/bin/sdkmanager "platform-tools" "platforms;android-${ANDROID_COMPILE_SDK}" >/dev/null
#- echo y | android-sdk-linux/tools/bin/sdkmanager "platform-tools" >/dev/null
- echo y | android-sdk-linux/tools/bin/sdkmanager "build-tools;${ANDROID_BUILD_TOOLS}" >/dev/null
- export ANDROID_HOME=$PWD/android-sdk-linux
- export PATH=$PATH:$PWD/android-sdk-linux/platform-tools/
- chmod +x ./gradlew
# temporarily disable checking for EPIPE error and use yes to accept all licenses
- set +o pipefail
- yes | android-sdk-linux/tools/bin/sdkmanager --licenses
- set -o pipefail
stages:
- build
- test
lintDebug:
stage: build
script:
- ./gradlew -Pci --console=plain :app:lintDebug -PbuildDir=lint
assembleDebug:
stage: build
script:
- ./gradlew assembleDebug
artifacts:
paths:
- app/build/outputs/
debugTests:
stage: test
script:
- ./gradlew -Pci --console=plain :app:testDebug
推荐答案
让我们深入研究真正的原因,而不是为每次执行单个命令都传递参数--sdk_root
.
Instead of passing the argument --sdk_root
for each single command execution, let's deep dive into the real cause.
从 Android SDK命令行工具1.0.0(6200805)开始,与 Android SDK 26.1.1(4333796)相反,tools
目录层次结构已经变了.
以前它被放置在ANDROID_HOME
内部,现在它仍被命名为tools
(解压缩下载的 commandlinetools zip文件后唯一得到的东西),但是不同的是,您必须将其放置在您自己的名为cmdline-tools
的目录中.名称cmdline-tools
来自其程序包名称,您可以从列表程序包命令sdkmanager --list
中获得该命令,其输出包括cmdline-tools;1.0 | 1.0 | Android SDK Command-line Tools
.
Starting from Android SDK Command-line Tools 1.0.0 (6200805), in contrast to Android SDK 26.1.1 (4333796), the tools
directory hierarchy has been changed.
Previously it was placed right inside ANDROID_HOME
, now it's still named as tools
(the only thing you'll get after unpacking the downloaded commandlinetools zip file), but differently, you have to place it inside a directory called cmdline-tools
on your own. The name cmdline-tools
comes from its package name, where you can get from listing packages command sdkmanager --list
, whose outputs include cmdline-tools;1.0 | 1.0 | Android SDK Command-line Tools
.
在cmdline-tools
目录中包装tools
目录将使其起作用,并帮助您摆脱烦人的--sdk_root
参数.但是其他部分呢?
Wrapping tools
directory inside cmdline-tools
directory would make it work, and help you get rid of the annoying --sdk_root
argument. But what about the other parts?
好吧,这就是您需要更改的所有内容.让我解释更多.
Well, that's all you have to change. Let me explain more.
- 国王-
sdkmanager
生活在cmdline-tools/tools/bin
内部,最好在PATH
环境变量中设置 -
cmdline-tools
不应设置为ANDROID_HOME
.因为稍后,当更新Android SDK或安装更多软件包时,其他软件包将放在ANDROID_HOME
下,而不是在cmdline-tools
下. - 最终的,完整的
ANDROID_HOME
目录结构应如下所示,由许多子目录组成:build-tools
,cmdline-tools
,emulator
,licenses
,patcher
,platform-tools
,platforms
,system-images
.您可以轻松地指出build-tools
和cmdline-tools
是兄弟姐妹,都位于父级ANDROID_HOME
内.
- The king -
sdkmanager
lives insidecmdline-tools/tools/bin
, you'd better set inPATH
environment variable cmdline-tools
should not be set asANDROID_HOME
. Because later, when updating Android SDK, or installing more packages, the other packages will be placed underANDROID_HOME
, but not undercmdline-tools
.- The final, complete
ANDROID_HOME
directory structure should look like below, consist of quite a few sub-directories:build-tools
,cmdline-tools
,emulator
,licenses
,patcher
,platform-tools
,platforms
,system-images
. You can easily point out thatbuild-tools
andcmdline-tools
are siblings, all sit inside the parentANDROID_HOME
.
让我以简单的方式回顾一下:
Let me recap in a simple way:
- 设置您喜欢的
ANDROID_HOME
(就像以前一样) - 下载 commandlinetools zip文件并将其解压缩到名为
cmdline-tools
的目录中,该目录位于ANDROID_HOME
内部
- 将目录
$ANDROID_HOME/cmdline-tools/tools/bin
附加到环境变量PATH
,以便系统知道在何处查找sdkmanager
- Set your preferred
ANDROID_HOME
(just like before) - Download and unpack the commandlinetools zip file into a directory called
cmdline-tools
, which is insideANDROID_HOME
- Append the directory
$ANDROID_HOME/cmdline-tools/tools/bin
to environment variablePATH
, so that the system knows where to findsdkmanager
这篇关于Android命令行工具sdkmanager始终显示:警告:无法创建设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!