本文介绍了Macbook M1 上的 Android Studio 错误:尝试计算所需的包时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在官网下载了Android Studio,M1芯片(arm)的那个.

I've downloaded Android Studio from the official website, the one for M1 chip (arm).

基本第一次运行,报错如下:

Basically running it for the first time, the error is the following:

An error occurred while trying to compute required packages

我一整天都在搜索它以找出一种使 Android Studio 工作的方法,但该错误一直显示.不完全确定它是否与 M1 Macbook 有关,就像在我的英特尔 Macbook 上一样,它按预期工作.

I was searching about it the whole day to figure out a way to make Android Studio work, but that error keeps showing. Not completely sure if it's related to M1 Macbook, as on my Intel one it works as expected.

我已经尝试过的:

  • 安装命令行工具,然后将其放置在 SDK 文件夹 (Users/user/Library/Android/sdk) 中.然后将 bin 添加到 PATH (参考)

  • Installing the command line tools, then placing it on SDK folder (Users/user/Library/Android/sdk). Then added the bin to the PATH (Reference)

  • 这样做之后,在终端上执行 sdkmanager 时,我收到以下消息 Could not find or load main class com.android.sdklib.tool.sdkmanager.SdkManagerCli
  • 然后我再次搜索,它引导我到 这个线程,然后就像我尝试重命名文件夹的答案一样,然后其他尝试不相关.我陷入了许多根本不起作用的链接和参考资料.
  • After doing that, when executing the sdkmanager on terminal I get the following message Could not find or load main class com.android.sdklib.tool.sdkmanager.SdkManagerCli
  • Then I searched again and it leaded me to this thread, then as on the answers I tried to rename the folder, then other tries not related. I fell into many links and references that did not work at all.

之后我尝试检查如果我点击New Project会发生什么,然后显示如下:

After that I try to check what happens if I click on New Project, then the following is shown:

Android SDK 位置不能在文件系统根目录

  • 如消息所示,问题是Android SDK 位置不能位于文件系统根目录,所以我再次搜索了它
    • 我研究了一下,找到了一些链接,例如 这个这个.在进行该搜索之前,我单击了编辑"按钮,这将引导我更新/安装 Android SDK(很好!),因此我必须删除我在 Android 文件夹(库内)上的内容,然后单击下一步...然后,我收到了相同的消息 尝试计算所需的包时出错.
    • 然后我想好吧,也许如果我更改 SDK 位置",所以我更改为 ../Documents/sdk,结果是相同的结果
      • As the message indicates, the issue is The Android SDK location cannot be at the filesystem root, so I searched again about it
        • I looked into that and got to a few links, for example this one and this one. Before doing that search I clicked on the Edit button, which lead me to the Android SDK to be updated/installed (Nice!), so I had to delete the content I had on Android folder (inside Library) and clicked next...then, I got the same message An error occurred while trying to compute required packages.
        • Then I thought "ok, maybe if I change the SDK location", so I changed to ../Documents/sdk, which ended up in the same result
        • 似乎无论我做什么,它最终都会显示相同的消息.

          Seems like no matter what I do, it ends up showing up that same message.

          当我运行 java -version 这就是我所看到的:

          When I run java -version that's what I see:

          java version "1.8.0_311"
          Java(TM) SE Runtime Environment (build 1.8.0_311-b11)
          Java HotSpot(TM) 64-Bit Server VM (build 25.311-b11, mixed mode)
          

          有人遇到过同样的问题吗?难道我做错了什么?不知道如何从这里开始,尽管我下载了 Android Studio 版本,但结果总是相同.

          Did anyone have the same issue? Am I doing something wrong? Not sure how to proceed from here, despite of the Android Studio version I download it's always the same result.

          感谢任何帮助.

          推荐答案

          这就是我在 M1 上为我解决的问题.

          This is what solved it for me on my M1.

          1. 转到 Android Studio Preview 并下载适用于 Apple 芯片 (Chipmunk) 的最新 Canary 版本.别担心,这只是为了完成初始设置.
          2. 像往常一样解压、运行、安装所有 SDK 组件、接受许可等.
          3. 完成后,只需将其关闭并删除即可.
          1. Go to Android Studio Preview and download the latest Canary build for Apple chip (Chipmunk). Don't worry this is just to get through the initial setup.
          2. Unpack it, run it, let it install all the SDK components, accept licenses, etc as usual.
          3. Once it's done, simply close it and delete it.

          现在,当您启动稳定的 Android Studio (Arctic Fox) 时,您应该不会看到错误.

          Now when you start your stable Android Studio (Arctic Fox) you should not see the error.

          这篇关于Macbook M1 上的 Android Studio 错误:尝试计算所需的包时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-07 21:02