主要版本53比52更新,这个编译器支持的最高主要版本是52。Android Studio

huangapple go评论71阅读模式
英文:

major version 53 is newer than 52, the highest major version supported by this compiler. Android studio

问题

我在编译时收到一个警告,内容如下:

> 任务:app:compileDebugJavaWithJavac
警告:C:\Users\bleuc\AppData\Local\Android\Sdk\build-tools.0.1\core-lambda-stubs.jar
(java/lang/invoke/LambdaMetafactory.class):主版本 53 比 52 新,此编译器支持的最高主版本为 52。
建议升级编译器。
C:\Users\bleuc\AppData\Local\Android\Sdk\build-tools.0.1\core-lambda-stubs.jar
(java/lang/invoke/LambdaMetafactory.class):主版本 53 比 52 新,此编译器支持的最高主版本为 52。

1 个警告

我应该如何解决这个问题?我正在使用 Android Studio。

在我的模块:app 中,

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}


我知道 53 对应 Java 9,所以我尝试使用 1_9,但是出现了很多错误。

帮帮我!我不知道如何在 Android Studio 中纠正这个问题。

<details>
<summary>英文:</summary>

I got a warning while I compile it tells me :

    &gt; Task :app:compileDebugJavaWithJavac
    warning: C:\Users\bleuc\AppData\Local\Android\Sdk\build-tools.0.1\core-lambda- 
    stubs.jar(java/lang/invoke/LambdaMetafactory.class): major version 53 is newer than 52, the highest 
    major version supported by this compiler.
    It is recommended that the compiler be upgraded.
    C:\Users\bleuc\AppData\Local\Android\Sdk\build-tools.0.1\core-lambda- 
    stubs.jar(java/lang/invoke/LambdaMetafactory.class): major version 53 is newer than 52, the highest 
    major version supported by this compiler.

1 warning

How can I resolve this? I&#39;m using android studio.

In my module:app 


    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
I know 53 is java 9 so I tried to pout 1_9 but it shows me so much errors.

Up! I don&#39;t know how to correct this on Android studio

</details>


# 答案1
**得分**: 11

好的,这是你要的翻译:

嗯,我在`build.gradle`中(应用级别,例如:模块:YourApp.app)将`buildToolsVersion`更新为了"30.0.2",然后警告消失了。

```groovy
apply plugin: 'com.android.application'

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.2"

    defaultConfig {
        applicationId "com.app"
        minSdkVersion 20
        targetSdkVersion 30
        versionCode 1
        versionName "0.0.1"
    }

    ...
}
英文:

Well, i updated my buildToolsVersion in build.gradle (app level, e.g. Module: YourApp.app) "30.0.2" and the warning disapeard.

apply plugin: &#39;com.android.application&#39;

android {
    compileSdkVersion 30
    buildToolsVersion &quot;30.0.2&quot;

    defaultConfig {
        applicationId &quot;com.app&quot;
        minSdkVersion 20
        targetSdkVersion 30
        versionCode 1
        versionName &quot;0.0.1&quot;
    }

    ...
}

答案2

得分: 0

让我们以 Windows 为例,如果您的操作系统的 JRE 版本是 Java 8 (52),而您的程序是用 Java 14 (58) 编译的,您将会遇到类似的错误。然而,如果您指定程序使用 JDK 14 二进制文件运行,它将会正常运行。

简而言之,检查一下您系统中默认的 JRE 版本,如果比您用来编译的版本旧,就会出现这个错误。请注意,在集成开发环境中可能不会出现问题,因为您设置了较新版本的 JRE。

确保正确关联 .jar 文件与支持的 JRE,这样它将会使用正确的 JRE 运行可执行文件。

英文:

Let's take Windows as an example, if your OS's JRE is Java 8 (52), while your program is complied in Java 14 (58), you will face a similar error. However, if you specify the program to run with JDK 14 binary, it will run normally.

In short, check what your system default JRE is, if it's older than the one you use to compile, you will have this error. Note that you might not face any issue in IDE since you set your IDE to use newer version of JRE.

Make sure to properly associate the .jar file with the supported JRE, so it will you the correct JRE to run the executable.

huangapple
  • 本文由 发表于 2020年9月10日 00:58:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/63816227.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定