SDKmanager:警告:无法创建设置。 java.lang.IllegalArgumentException

时间:2020-03-17 21:40:19

标签: java android ubuntu

我正在尝试在Ubuntu上安装androidSDK,但是当我尝试在tools / bin / sdkmanager文件夹上运行SDK管理器时,出现以下消息:

我的Ubuntu是最近安装的,除了Java 8和Android Studio之外,上面什么都没有。

我的SDK文件夹是默认的〜/ Android / Sdk。

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)
Usage:
  sdkmanager [--uninstall] [<common args>] [--package_file=<file>] [<packages>...]
  sdkmanager --update [<common args>]
  sdkmanager --list [<common args>]
  sdkmanager --licenses [<common args>]
  sdkmanager --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 sdkmanager.

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. ```

3 个答案:

答案 0 :(得分:20)

弄乱控制台之后,我想我发现了正在发生的事情。 显然,SDK定位SDK安装文件夹的方式存在错误。

因此,在我使用 export ANDROID_HOME =〜/ Android / Sdk <>导出路径后,我需要使用-sdk_root = $ {ANDROID_HOME} 来指定它/ p>

因此完整命令为是| 〜/ Android / Sdk / tools / bin / sdkmanager --sdk_root = $ {ANDROID_HOME} --version

从另一篇文章中找到解决方案:Android Command line tools sdkmanager always shows: Warning: Could not create settings

答案 1 :(得分:11)

Android SDK工具现在位于以下位置:“ android_sdk / cmdline-tools / version / bin / ”;

因此,要在 Windows 中解决此问题(可以在其他操作系统中复制相同的内容),请执行以下操作:

  1. 在您的android_sdk文件夹中,创建文件夹:cmdline-tools,并在其中创建另一个文件夹:version提取/将所有文件“ / bin / lib注意和来源” “ .properties”文件放在此version文件夹中。

  2. ANDROID_HOME设置到您的android_sdk文件夹中。

  3. 添加到您的系统路径:android_sdk\cmdlineAndroidSDK\cmdline-tools\version\bin\

类似地,将您的 Android SDK平台工具放入android_sdk/platform-tools/内,并将相应的PATH添加到ENVIRONMENTAL VARIABLES下的System Variables

答案 2 :(得分:0)

使用docs作为指导,我能够使其在Windows中将安装移动到以下路径:%LocalAppData%\Android\android-sdk\cmdline-tools\2.1对于版本2.1。类似于 shahab Uddin 的建议,但在-中使用_而不是android-sdk

可以在source.properties文件中检查您的版本。