本文介绍了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 有关,因为在我的 Intel 上它可以按预期工作.

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:03