简体   繁体   English

“android:找不到sdkmanager.jar”

[英]“android: can't find sdkmanager.jar”

I downloaded the Android SDK tools from https://developer.android.com/studio/index.html which gave me a zip file called tools_r25.2.3-linux.zip . 我从https://developer.android.com/studio/index.html下载了Android SDK工具,它给了我一个名为tools_r25.2.3-linux.zip的zip文件。 Unziped, it produced a folder called tools , containing the sdkmanager, android . Unziped,它生成了一个名为tools的文件夹,其中包含sdkmanager, android When I tried to run it, it failed with the error message above. 当我尝试运行它时,它失败并显示上面的错误消息。

I set ANDROID_HOME to the tools directory, but it still failed. 我将ANDROID_HOME设置为tools目录,但仍然失败。

It turns out that ANDROID_HOME needs to be set to the parent directory, with the contents of the zip file (a single directory named tools ) contained within it. 事实证明,需要将ANDROID_HOME设置为父目录,其中包含zip文件(名为tools的单个目录)的内容。 Once I did that, it worked fine. 一旦我这样做,它运作良好。 This seemed confusing enough to be worth adding to stackoverflow. 这似乎令人困惑,值得添加到stackoverflow。

The zip file can be opened anywhere. zip文件可以在任何地方打开。 The important thing is to leave the name "tools" and it's files intact. 重要的是留下名称“工具”,它的文件完好无损。

Run the android program from the tools parent directory as: 工具父目录运行android程序:

$ ./tools/android

This will update the tools parent directory (the one from where you are running ./tools/android ) with a number of folders and tools. 这将使用许多文件夹和工具更新工具父目录(运行./tools/android )。

I name this parent directory sdk . 我将此父目录命名为sdk I also place the whole directory (named sdk ) in a folder by the name of the downloaded version. 我还将整个目录(名为sdk )放在一个文件夹中,其名称为下载的版本。

Now for consistency of my programming environment I bind mount this sdk to a folder in the /opt directory so that it'll be available system-wide. 现在为了保持编程环境的一致性,我这个sdk 绑定/opt目录中的一个文件夹,以便它可以在系统范围内使用。

The hierarchy becomes: 层次结构变为:

/home/userid/android_r25.2.3/sdk

Now I make a folder in the /opt/ directory called /opt/android/sdk . 现在我在/opt/目录中创建一个名为/opt/android/sdk的文件夹。

My /etc/fstab entry for this becomes: 我的/etc/fstab条目变为:

/home/userid/android_r25.2.3/sdk  /opt/android/sdk none bind

It's mounted with: 它安装有:

$ sudo mount /opt/android/sdk

The only thing that changes with new versions or new installs is the location of where the zip file is opened. 新版本或新安装更改的唯一内容是zip文件的打开位置。 replace the /home/userid/android_r25.2.3/sdk with where you extract the zipfile and nothing else would ever have to be changed. /home/userid/android_r25.2.3/sdk替换为解压zip 文件的位置,其他任何内容都不需要更改。

The PATH variable will consistently become: PATH变量将始终如一:

$ export PATH=$PATH:/opt/android/sdk/tools:/opt/android/sdk/platform-tools

And, of course, the eclipse android configuration becomes: 当然,eclipse android配置变为:

/opt/android/sdk

Using this as a consistent procedure makes reinstalls and installs on new machines very seamless... having only one variable that might change, and that is where the package is extracted. 使用它作为一致的过程使得在新机器上重新安装和安装非常无缝......只有一个可能更改的变量,这就是提取包的地方。

One more issue is that one has to leave the name of the unzip result tools untouched and move it into a to be created directory in order to allow any version management (or leave it in your home directory if a information-free directory name like "tools" doesn't distrub you). 还有一个问题是,必须保持unzip结果tools的名称不变,并将其移动到要创建的目录中,以便允许任何版本管理(或者如果没有信息的目录名称,则将其保留在主目录中)工具“不会让你失望”。 Then set ANDROID_HOME like @JesseW explained. 然后像@JesseW一样设置ANDROID_HOME解释。

unzip tools into eg ~/android-sdk , so it will live at ~/android-sdk/tools 将工具解压缩到例如~/android-sdk ,所以它将存在于~/android-sdk/tools

then in ~/.bashrc 然后在~/.bashrc

export ANDROID_HOME="$HOME/android-sdk" ANDROID_TOOLS="$ANDROID_HOME/tools" ANDROID_PLATFORM_TOOLS="$ANDROID_HOME/platform-tools" export PATH=${PATH}:$ANDROID_TOOLS:$ANDROID_PLATFORM_TOOLS;

then run sdkmanager 然后运行sdkmanager

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM