无法找到 sdkmanager.bat。安装后是否运行了 Android Studio 并安装了 cmdline-tools?
我试图使用虚幻引擎 4 模板进行 AR,但出现此错误。这一步有点将 android studio 与 unreal 连接起来,但我就是不工作。
i was trying to make use of unreal engine 4 template for AR but i got this error. This step kinda connect android studio with unreal but i just don't work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
遇到了同样的问题,并通过编辑 SetupAndroid.bat 文件修复了它。
调整后的代码示例
不确定为什么在第一个失败后没有设置 SDKManager 的位置。但手动替换第一个位置是可行的。
Ran into the same issue and fixed it by editing the SetupAndroid.bat file.
Example of adjusted code
Not sure why it doesnt set the location of the SDKManager after it fails the first one. But manually replacing the first location works.
我没有工具目录,但我确实在 cmdline-tools 目录中拥有它,所以我只是用它替换了代码。
但后来我...
所以我通过下载目前版本 20 的 oracle java 修复了这个问题,然后将 Windows 用户变量中的 JAVA_HOME 设置
为
C:\Program Files\Java\jdk-20
然后我运行编辑后的 C:\Program Files\Epic Games\UE_4.27\Engine\Extras\Android\SetupAndroid.bat
一切都通过了
I didn't have a tools directory but I did have it in the
cmdline-tools
directory so I just replaced the code with this.but then i got...
So i fixed that by download oracle java which is currently at version 20 and then setting my JAVA_HOME in the windows user variables
to
C:\Program Files\Java\jdk-20
then i ran the edited C:\Program Files\Epic Games\UE_4.27\Engine\Extras\Android\SetupAndroid.bat
and everything passed
接下来尝试:
AppData\Local\Android\Sdk
文件夹sdkmanager.bat
SetupAndroid.bat
> 使用记事本(或您选择的其他编辑器)\cmdline-tools\latest\bin\sdkmanager.bat
)这对我有用。
Try next:
AppData\Local\Android\Sdk
foldersdkmanager.bat
SetupAndroid.bat
with Notepad (or other editor of your choice)sdkmanager.bat
\cmdline-tools\latest\bin\sdkmanager.bat
)This worked for me.
如果您在运行“SetupAndroid.bat”时遇到此问题,原因可能很简单。如果你勾选“SetupAndroid.bat”(右键编辑。或者将其转为txt),默认的sdkmanager路径可能与实际位置不同。
您可能需要手动从Android Studio SDK根文件夹中搜索“sdkmanager”(它应该显示在cmd界面上),找到实际目录并更正“SetupAndroid.bat”,然后重试。
if you encountered this issue when running "SetupAndroid.bat", the reason might be simple. If you check the "SetupAndroid.bat"(right click, edit. Or turn it into a txt), the default sdkmanager path might be different from the actual location.
You might need to search "sdkmanager" from the Android Studio SDK root folder manually(it suppose to display on the cmd interface), find the actual directory and correct the "SetupAndroid.bat", then try it again.
同样,我尝试在我的两个驱动器中搜索“sdkmanager”,但找不到任何内容。
也找不到任何 cmdline-tools 驱动器。
the same here, i tried to search "sdkmanager" at both of my Drive and couldn't find any.
couldn't find any cmdline-tools drive as well.
我花了2个小时才弄清楚它出了什么问题。
因此,提供的早期解决方案应该可以修复它:
只需将不正确的路径替换为正确的路径,或者删除最外部的 IF 块和第一行,其中 %SDKMANAGER% var 首先设置为无效(我想是过时的路径)值。
这是 Epic Games 的 SetupAndroid.bat 源代码的一部分。我检查过版本 4.27 和 5.1。这些行在两个版本中都是相同的(但是版本 5.1 仍然具有相同的错误,但它是由于更改了首先尝试的路径的顺序而起作用的):
并且这个特定部分不起作用!我不知道为什么那些开发者没有检查它,或者他们根本不知道批处理文件变量是如何工作的。
这里的问题是,在最近安装的 Android SDK 中,路径
%STUDIO_SDK_PATH%
处没有文件夹tools
。因此,第一个条件检查失败,然后他们尝试覆盖变量值以使用路径%STUDIO_SDK_PATH%\cmdline-tools\latest\bin
更正变量值。但这种覆盖不起作用。您不能只在批处理文件中执行此操作(这有点愚蠢,但确实如此)。有关批处理变量问题的更多信息:如何使用批处理文件中的另一个变量覆盖现有变量?“干得好!”史诗游戏
I spent 2 hours to figure out what's wrong with it.
So, provided earlier solutions should fix it:
Simply just replace incorrect path to correct one or, just DELETE most outer
IF
block and first line where%SDKMANAGER%
var first set to invalid (I suppose, outdated path) value.This is a part of the source code of SetupAndroid.bat from Epic Games. I've checked version 4.27 and 5.1. These lines are kind of identical in both versions (however version 5.1 still has the same exact error, but it works due to changing the order of which path is tried first):
And this specific part does not work! I don't know why those who developed that did not check it or they simply don't know how batch file variables work.
The thing here is that on recent Android SDK installations there's no folder
tools
at the path%STUDIO_SDK_PATH%
. So the first condition check fails and then they try to overwrite variable value to correct one with path%STUDIO_SDK_PATH%\cmdline-tools\latest\bin
. But this overwrite DOES NOT WORK. You can't just do that in a batch file (which is kind of stupid, but it is). More on that issue with batch vars here: How to overwrite an existing variable using another variable in batch files?"Good" job! Epic Games
它很简单,只需将 cmdline-tools 内的文件夹重命名为latest,它就应该找到它
It Simple just rename the folder inside cmdline-tools to latest and it should find it