简体   繁体   English

新 Android studio 4.2 预览版在创建 buildSrc 和 build.gradle.kts 时出现此错误

[英]New Android studio 4.2 Preview having this error when creating buildSrc and build.gradle.kts

I am trying to use buildSrc for dependency management in the new Android 4.2 Preview version and getting this error.我正在尝试在新的 Android 4.2 预览版中使用 buildSrc 进行依赖管理并收到此错误。

Cannot access 'java.lang.Object' which is a supertype of 'org.gradle.api.artifacts.repositories.MavenArtifactRepository'. Check your module classpath for missing or conflicting dependencies
Cannot access class 'java.net.URI'. Check your module classpath for missing or conflicting dependencies

I figured it out, it's due to the Java default JDK coming with the new Android Studio, I believe this will be fixed in the release version.我想通了,这是由于 Java 默认 JDK 与新的 Android Studio 一起提供的,我相信这将在发布版本中修复。

To quickly fix this there are two options:要快速解决此问题,有两种选择:

  1. Use the JDK of the previous release Android Studio if you have not deleted it (recommended because I tested that).如果没有删除,请使用上一版本 Android Studio 的 JDK(推荐因为我测试过)。
  2. Download Java JDK and install it and get it's directory and attach it to JDK directory in the new Android studio.下载 Java JDK 并安装并获取它的目录并将其附加到新 Android 工作室的 JDK 目录中。

How to change the JDK in Android studio.如何在 Android studio 中更改 JDK。

  1. File ->文件->
  2. Project Structure ->项目结构->
  3. On the left find "SDK Location" ->在左侧找到“SDK位置”->
  4. at the bottom you will find "JDK Location" change this to the same directory either of the old Android studio or the location of Java JDK that you installed manually from Oracle official website.在底部,您会发现“JDK Location”将其更改为旧 Android 工作室或您从 Oracle 官方网站手动安装的 Java JDK 的位置的同一目录。
  1. delete project/.idea folder删除project/.idea文件夹

  2. delete project/.gradle folder删除project/.gradle文件夹

  3. restart and reopen the project重新启动并重新打开项目

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ClassNotFoundException: kotlin.KotlinNothingValueException 使用带有 build.gradle.kts 的 Android Studio 4.2 Canary 8 - ClassNotFoundException: kotlin.KotlinNothingValueException using Android Studio 4.2 Canary 8 with build.gradle.kts android build.gradle.kts 风格的实现 - android build.gradle.kts flavoured implementation Android Studio 4.2 doesn't recognize any syntax in KotlinScript Gradle build.gradle.kts, even though 4.1.3 works fine with Gradle 7.0 - Android Studio 4.2 doesn’t recognize any syntax in KotlinScript Gradle build.gradle.kts, even though 4.1.3 works fine with Gradle 7.0 Android Studio:如何在 Kotlin 多平台共享模块 build.gradle.kts 中访问项目级 compileSdkVersion 和 targetSdkVersion? - Android Studio: How to access project level compileSdkVersion and targetSdkVersion in Kotlin Multiplatform shared module build.gradle.kts? androidTest Groovy 模拟 build.gradle.kts - androidTest Groovy analog in build.gradle.kts 未解决的参考:build.gradle.kts 中的 grgit - Unresolved reference: grgit in build.gradle.kts 从 build.gradle 迁移到 build.gradle.kts 时出现一些代码片段问题 - Migrating from build.gradle to build.gradle.kts having issue with some code snippets gradle kotlin-dsl move android {} into subproject {} in root project build.gradle.kts - gradle kotlin-dsl move android {} into subproject {} in root project build.gradle.kts 如何将文档字符串添加到 build.gradle.kts 中的 android maven-publish.aar 文件? - How can I add docstrings to android maven-publish .aar files in build.gradle.kts? App build.gradle.kts文件未解决的参考Erros - App build.gradle.kts File Unresolved Reference Erros
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM