如何修复“模块 java.base 无法“打开 java.io"?Android Studio 中的未命名模块 '' 错误? [英] How to fix the ''module java.base does not "opens java.io" to unnamed module '' error in Android Studio?

查看:43
本文介绍了如何修复“模块 java.base 无法“打开 java.io"?Android Studio 中的未命名模块 '' 错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景

  1. 为了熟悉 Android 编程,我在 android studio 开始了我的第一个项目.
  2. 我正在关注这个教程,其中

  • 我创建了一个新项目 Empty Activity,没有任何更改
  • 它应该模拟一个显示Hello World"的简单应用程序.留言

问题描述但是每次我尝试运行和构建(我现在想要模拟器)时,我都会收到以下错误消息.

无法使字段私有 final java.lang.String java.io.File.path 可访问:无法使字段私有最终 java.lang.String java.io.File.path可访问:模块 java.base 不会打开 java.io";到未命名的模块@42760a00

这是我的配置设置:

  1. Android Gradle 插件版本:4.2.1
  2. Gradle 版本:7.0.1(已更改以解决我在同步 Gradle 时遇到的另一个问题(Gradle 同步失败:不支持的类文件主要版本 60")和基于此的讨论 论坛 如下引用)

<块引用>

Andrey Dernov 于 2021 年 4 月 14 日 00:18 发表评论,请使用 Gradle 7.0 或 JDK用于导入和构建项目的小于 16 版本(设置(macOS 上的首选项)|构建、执行、部署 |构建工具 |摇篮 |Gradle JVM 选项).

  1. JDK:16.0.1

有什么建议或想法吗?

解决方案

我发现了这个 讨论 与我的问题有关.但是不知道如何在Android studio中传递JVM参数.

但是,用 JDK 15 替换 JDK 16 后错误消失了.

Background

  1. I started my first project in android studio to get familiar with Android programming.
  2. I am following this tutorial, in which

  • I created a new project Empty Activity, without any change
  • It is supposed to simulate a simple app that shows "Hello World" message

Problem Description But every time I try to run and build (I want to emulator as of now), I get the following error message.

Unable to make field private final java.lang.String java.io.File.path accessible:
Unable to make field private final java.lang.String java.io.File.path
accessible: module java.base does not "opens java.io" to unnamed module @42760a00

Here is my config set-up:

  1. Android Gradle plugin version: 4.2.1
  2. Gradle Version: 7.0.1 (changed to fix another issue I had while syncing the Gradle ("Gradle sync failed: Unsupported class file major version 60") and based discussion on this forum as quoted below)

Andrey Dernov commented 14 Apr 2021 00:18 Please use Gradle 7.0 or JDK less than 16 version for importgin and building the project (Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Gradle | Gradle JVM option).

  1. JDK: 16.0.1

Any suggestion or idea?

解决方案

I found this discussion kind of related to my question. But could not figure out how to pass JVM parameters in Android studio.

But, the error is gone after replacing JDK 16 by JDK 15.

这篇关于如何修复“模块 java.base 无法“打开 java.io"?Android Studio 中的未命名模块 '' 错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆