You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mac mini M1 2020使用Android Studio运行Instant App失败求助

Mac M1设备上Android Studio运行Instant App失败的解决方案

问题概述

  • 设备:Mac mini M1 2020
  • Android Studio版本:Flamingo 2022.2.1 patch 2、Giraffe 2022.3.1
  • 核心问题:已正确配置instant.main模块并勾选「Deploy as instant app」,但在M1设备上运行Instant App始终失败;模拟器、物理设备均出现异常;升级至Giraffe版本后触发错误:could not initialize class com.google.android.instantapps.sdk.lib.ClearcutLogger
  • 对比:相同配置与版本的Windows设备可正常运行

可行解决步骤

1. 通过Rosetta运行Android Studio

M1的ARM架构可能与部分Instant Apps依赖的x86库存在兼容问题,用Rosetta转译可解决:

  • 找到应用程序中的Android Studio图标,右键选择「显示简介」
  • 勾选「使用Rosetta打开」
  • 重启Android Studio后重新尝试部署Instant App

2. 验证Instant Apps SDK组件

  • 打开Android Studio的SDK Manager,切换到「SDK Tools」标签
  • 确认已安装Instant Apps SDK组件,若存在ARM64版本优先选择;若无则尝试卸载后重新安装该组件

3. 清除缓存并重建项目

缓存损坏可能导致模块加载异常:

  • 点击顶部菜单栏「File」→「Invalidate Caches...」
  • 勾选「Clear file system cache and local history」,点击「Invalidate and Restart」
  • 重启后执行「Build」→「Clean Project」,再执行「Build」→「Rebuild Project」

4. 调整Gradle依赖与配置

  • 在项目根目录的build.gradle(Project级别)中,确保Instant Apps依赖为最新兼容版本:
    buildscript {
        dependencies {
            classpath 'com.google.android.gms:play-services-instantapps:17.0.0'
        }
    }
    
  • 在instant.main模块的build.gradle中,确认插件与配置正确:
    apply plugin: 'com.google.android.gms.instantapps'
    
    android {
        defaultConfig {
            // 确保targetSdkVersion ≥ 26,minSdkVersion ≥ 21(Instant Apps最低要求)
        }
    }
    

5. 切换兼容的JDK版本

Giraffe默认使用JDK 17,部分Instant Apps库可能存在版本适配问题:

  • 打开「File」→「Project Structure」→「SDK Location」
  • 将JDK路径切换为Android Studio自带的JDK(路径通常为/Applications/Android Studio.app/Contents/jbr/Contents/Home)
  • 若仍有问题,尝试切换至JDK 11版本

内容的提问来源于stack exchange,提问作者pd200

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 16:12:38