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

Android Studio中Chrome模拟器localhost不安全证书设置无法持久化如何解决

持久启用Android Studio Chrome模拟器的"Allow invalid certificates for resources loaded from localhost"设置

方法1:通过adb命令启动Chrome并指定参数

  • 启动Android模拟器后,打开终端执行以下命令:
    1. 连接到模拟器shell:adb shell
    2. 启动Chrome并启用不安全localhost证书:am start -n com.android.chrome/com.google.android.apps.chrome.Main --args="--allow-insecure-localhost"
  • 每次用这个命令启动Chrome,该设置都会自动生效,无需手动在flags里修改。

方法2:修改Chrome偏好配置文件(需模拟器root)

  • 先在AVD管理器中编辑目标模拟器,勾选Enable root access并重启模拟器。
  • 打开终端执行:
    1. 进入模拟器root shell:adb shell su
    2. 编辑Chrome偏好文件:vi /data/data/com.android.chrome/app_chrome/Default/Preferences
    3. 在文件中找到"allow_insecure_localhost"字段,将其值改为true
    4. 保存退出后重启Chrome,设置即可持久化。
  • 注意:若模拟器重置或Chrome版本更新,该配置可能被覆盖,需重新修改。

方法3:在Android Studio Run配置中添加模拟器启动参数

  • 打开Android Studio的Run/Debug Configurations
  • 选择你的项目配置,切换到Emulator标签页
  • 在Additional command line options输入框中添加:-chrome-options "--allow-insecure-localhost"
  • 保存配置后,每次运行项目启动模拟器时,Chrome会自动加载该设置。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.25 22:48:32