Android sdkmanager为任何参数提供IllegalArgumentException

问题描述

我在docker内部安装了android SDK。无论将什么参数传递给SDK,我都会收到关于非法参数的相同错误。示例:

RUN $ANDROID_HOME/tools/bin/@R_177_5025@ager --version

RUN $ANDROID_HOME/tools/bin/@R_177_5025@ager "platform-tools" "platforms;android-28"

我明白了

Warning: Could not create settings
java.lang.IllegalArgumentException
    at com.android.sdklib.tool.@R_177_5025@ager.@R_177_5025@agerCliSettings.<init>(@R_177_502[email protected]:428)
    at com.android.sdklib.tool.@R_177_5025@ager.@R_177_502[email protected](@R_177_502[email protected]:152)
    at com.android.sdklib.tool.@R_177_5025@ager.@R_177_502[email protected](@R_177_502[email protected]:134)
    at com.android.sdklib.tool.@R_177_5025@ager.@R_177_502[email protected](@R_177_502[email protected]:57)
    at com.android.sdklib.tool.@R_177_5025@ager.@R_177_502[email protected](@R_177_502[email protected]:48)
Usage:
  @R_177_5025@ager [--uninstall] [<common args>] [--package_file=<file>] [<packages>...]
  @R_177_5025@ager --update [<common args>]
  @R_177_5025@ager --list [<common args>]
  @R_177_5025@ager --licenses [<common args>]
  @R_177_5025@ager --version

With --install (optional),installs or updates packages.
    By default,the listed packages are installed or (if already installed)
    updated to the latest version.
With --uninstall,uninstall the listed packages.

    <package> is a sdk-style path (e.g. "build-tools;23.0.0" or
             "platforms;android-23").
    <package-file> is a text file where each line is a sdk-style path
                   of a package to install or uninstall.
    Multiple --package_file arguments may be specified in combination
    with explicit paths.

With --update,all installed packages are updated to the latest version.

With --list,all installed and available packages are printed out.

With --licenses,show and offer the option to accept licenses for all
     available packages that have not already been accepted.

With --version,prints the current version of @R_177_5025@ager.

Common Arguments:
    --sdk_root=<sdkRootPath>: Use the specified SDK root instead of the SDK
                              containing this tool

    --channel=<channelId>: Include packages in channels up to <channelId>.
                           Common channels are:
                           0 (Stable),1 (Beta),2 (Dev),and 3 (Canary).

    --include_obsolete: With --list,show obsolete packages in the
                        package listing. With --update,update obsolete
                        packages as well as non-obsolete.

    --no_https: Force all connections to use http rather than https.

    --proxy=<http | socks>: Connect via a proxy of the given type.

    --proxy_host=<IP or DNS address>: IP or DNS address of the proxy to use.

    --proxy_port=<port #>: Proxy port to connect to.

    --verbose: Enable verbose output.

* If the env var REPO_OS_OVERRIDE is set to "windows","macosx",or "linux",packages will be downloaded for that OS.

可能是什么原因造成的?我遵循了这个规则:https://hub.docker.com/r/chibatching/docker-android-sdk/dockerfile

解决方法

更正。

Linux发生在我身上。我使用了--sdk_root,它起作用了。

例如: 如果工具安装在$ANDROID_HOME中,并且工具位于 $ANDROID_HOME/tools,我必须使用此选项--sdk_root=$ANDROID_HOME

然后运行

$ANDROID_HOME/tools/bin/sdkmanager --list --sdkroot=$ANDROID_HOME