无头 linux 上的“android 更新 sdk”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2157089/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 04:45:06  来源:igfitidea点击:

"android update sdk" on headless linux

android

提问by focuser

Has anybody succeeded in updating/installing Android SDK platforms on a headless Linux server? All I got is the following error:

有没有人成功地在无头 Linux 服务器上更新/安装 Android SDK 平台?我得到的只是以下错误:

It seems like the action "update sdk" is actually not supported?

似乎实际上不支持“更新 sdk”操作?

~/android-sdk-linux_86/tools$ ./android --verbose update sdk
No command line parameters provided, launching UI.
See 'android --help' for operations from the command line.
Exception in thread "main" java.lang.UnsatisfiedLinkError: no swt-pi-gtk-3550 or swt-pi-gtk in swt.library.path, java.library.path or the jar file
        at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
        at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
        at org.eclipse.swt.internal.gtk.OS.<clinit>(Unknown Source)
        at org.eclipse.swt.internal.Converter.wcsToMbcs(Unknown Source)
        at org.eclipse.swt.internal.Converter.wcsToMbcs(Unknown Source)
        at org.eclipse.swt.widgets.Display.<clinit>(Unknown Source)
        at com.android.sdkuilib.internal.repository.UpdaterWindowImpl.open(UpdaterWindowImpl.java:93)
        at com.android.sdkuilib.repository.UpdaterWindow.open(UpdaterWindow.java:110)
        at com.android.sdkmanager.Main.showMainWindow(Main.java:281)
        at com.android.sdkmanager.Main.doAction(Main.java:251)
        at com.android.sdkmanager.Main.run(Main.java:92)
        at com.android.sdkmanager.Main.main(Main.java:81)

Update: The question was asked a while ago when headless update wasn't supported. It is now possible to do just a android update sdk --no-ui. Thanks folks!

更新:不久前在不支持无头更新时提出了这个问题。现在可以只做一个android update sdk --no-ui. 谢谢各位!

采纳答案by Diego Torres Milano

Updating Android SDK headless and automatically is described in is-there-a-way-to-automate-the-android-sdk-installation

is-the-a-way-to-automate-the-android-sdk-installation 中描述了无头和自动更新 Android SDK

回答by x2on

You can use the --no-uioption:

您可以使用以下--no-ui选项:

android update sdk --no-ui

If you'd like to automate it, you could accept all licenses by using the expecttool with this hack (the --accept-licenseoption is currently not fully integrated in the androidtool):

如果您想自动化它,您可以通过使用expect带有此 hack的工具来接受所有许可证(该--accept-license选项目前未完全集成到该android工具中):

expect -c '
set timeout -1;
spawn android - update sdk --no-ui;
expect {
    "Do you accept the license" { exp_send "y\r" ; exp_continue }
    eof
}
'

回答by Marc

I just ran into the same problem. I found a workaround though.

我刚刚遇到了同样的问题。不过我找到了解决方法。

The first one is a cop-out: Download the platforms on a headed system and simply copy the platform subdirectories into your android sdk/platforms dir.

第一个是逃避:在有头系统上下载平台,然后简单地将平台子目录复制到您的 android sdk/platforms 目录中。

If, like me, you don't have immediate access to another headed android dev environment, you can go to Google's SDK archives and download one of the other SDK's that included the platforms. This way means that you can only develop for Android 1.1 and 1.5 though.

如果像我一样,您无法立即访问另一个主导的 android 开发环境,您可以转到 Google 的 SDK 档案并下载包含这些平台的其他 SDK 之一。这种方式意味着您只能针对 Android 1.1 和 1.5 进行开发。

The download to get for linux systems is their Android 1.5 r3. Of course, google's sdk download pages aren't lynx-friendly, so I had to get the direct link from another GUI system.

用于 linux 系统的下载是他们的 Android 1.5 r3。当然,google 的 sdk 下载页面不是 lynx 友好的,所以我不得不从另一个 GUI 系统获取直接链接。

wget http://dl.google.com/android/archives/android-sdk-linux_x86-1.5_r3.zip

Then it's simply a matter of unzipping the archive, and moving the platform sibdirs to your newer SDK platform dir.

然后只需解压缩存档并将平台 sibdirs 移动到较新的 SDK 平台目录即可。

android create avd -t 3 -p path/to/avd/dir -n "name"

This creates an AVD for the 1.5 platform with your specified name and directory. Note that the avd dir shouldn't exist. If you want to overwrite, add --force to the command.

这将使用您指定的名称和目录为 1.5 平台创建一个 AVD。请注意,avd 目录不应该存在。如果要覆盖,请将 --force 添加到命令中。

Getting this far has a platform installed and creates an AVD. Unfortunately, trying to build failed at this point for me because I run a 64bit server, and google only releases 32bit tools.

到目前为止,已经安装了一个平台并创建了一个 AVD。不幸的是,此时尝试构建失败了,因为我运行的是 64 位服务器,而 google 仅发布 32 位工具。

I found a solution for this in the accepted answer of this stackoverflow questionand used sudo apt-get install ia32-libsto enable the ability to run the 32bit tools.

我在这个 stackoverflow 问题的公认答案中找到了一个解决方案,并用于sudo apt-get install ia32-libs启用运行 32 位工具的能力。

Then you should be able to use the android tool on the CLI to either convert an eclipse project (for 1.5 or lower) to have an ant build system, or you can have it create a new project for you to start working on.

然后您应该能够使用 CLI 上的 android 工具将 eclipse 项目(1.5 或更低版本)转换为具有 ant 构建系统,或者您可以让它创建一个新项目供您开始工作。

Hope this helps!

希望这可以帮助!

回答by cheetah

I just created a small command line tool that does the update in any environment (GUI or non-GUI). Didn't have the chance to test it extensively, but as far as I can tell it does what it should.

我刚刚创建了一个小型命令行工具,可以在任何环境(GUI 或非 GUI)中进行更新。没有机会对其进行广泛的测试,但据我所知,它应该做什么。

The command line tool updates a pre-installed base Android SDK with all currently available platforms, add-ons, extras, docs, samples and tools. This should be enough for a build server (I need this for my Hudson CI installation with Maven).

命令行工具使用所有当前可用的平台、附加组件、附加组件、文档、示例和工具更新预安装的基础 Android SDK。这对于构建服务器来说应该足够了(我的 Hudson CI 安装需要使用 Maven)。

Please go here for more details:

请到这里了解更多详情:

http://code.google.com/p/android-sdk-tool

http://code.google.com/p/android-sdk-tool

回答by Jason

Yes, it works but you need the GUI libraries installed and you need your DISPLAY set to what X server you want it to display. I have it working now on CentOS 5.4 and had to use the "Server - GUI" verse "Server" install option. Then I just use "ssh -X" from the system where I want it to display.

是的,它可以工作,但您需要安装 GUI 库,并且您需要将 DISPLAY 设置为您希望它显示的 X 服务器。我现在在 CentOS 5.4 上运行它,并且不得不使用“服务器 - GUI”和“服务器”安装选项。然后我只使用我希望它显示的系统中的“ssh -X”。