<bdo id='D90qS'></bdo><ul id='D90qS'></ul>
  • <legend id='D90qS'><style id='D90qS'><dir id='D90qS'><q id='D90qS'></q></dir></style></legend>
    1. <small id='D90qS'></small><noframes id='D90qS'>

    2. <tfoot id='D90qS'></tfoot>

        <i id='D90qS'><tr id='D90qS'><dt id='D90qS'><q id='D90qS'><span id='D90qS'><b id='D90qS'><form id='D90qS'><ins id='D90qS'></ins><ul id='D90qS'></ul><sub id='D90qS'></sub></form><legend id='D90qS'></legend><bdo id='D90qS'><pre id='D90qS'><center id='D90qS'></center></pre></bdo></b><th id='D90qS'></th></span></q></dt></tr></i><div id='D90qS'><tfoot id='D90qS'></tfoot><dl id='D90qS'><fieldset id='D90qS'></fieldset></dl></div>

        得到“不支持的类文件版本 52.0"在将模块包含

        时间:2023-09-28

        <tfoot id='YrrN0'></tfoot>

                <small id='YrrN0'></small><noframes id='YrrN0'>

                  <tbody id='YrrN0'></tbody>
              1. <legend id='YrrN0'><style id='YrrN0'><dir id='YrrN0'><q id='YrrN0'></q></dir></style></legend>
                • <bdo id='YrrN0'></bdo><ul id='YrrN0'></ul>
                • <i id='YrrN0'><tr id='YrrN0'><dt id='YrrN0'><q id='YrrN0'><span id='YrrN0'><b id='YrrN0'><form id='YrrN0'><ins id='YrrN0'></ins><ul id='YrrN0'></ul><sub id='YrrN0'></sub></form><legend id='YrrN0'></legend><bdo id='YrrN0'><pre id='YrrN0'><center id='YrrN0'></center></pre></bdo></b><th id='YrrN0'></th></span></q></dt></tr></i><div id='YrrN0'><tfoot id='YrrN0'></tfoot><dl id='YrrN0'><fieldset id='YrrN0'></fieldset></dl></div>
                  本文介绍了得到“不支持的类文件版本 52.0"在将模块包含到项目中之后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  在 Android Studio 中创建一个空项目并包含一个纯 java 模块后,该模块可以自行编译和完美运行,我在该模块中的每个类上都收到以下错误:

                  After creating an empty project within Android Studio and including a pure java module, which compiles and works perfectly on its own, I get the following error on every single class within that module:

                  Error:PARSE ERROR: Error:unsupported class file version 52.0

                  我尝试使用嵌入式 JDK 和我系统上的 JDK 8 (1.8.0_91) 运行项目,结果是一样的.

                  I tried to run the project using the embedded JDK and the one that I have on my system - JDK 8 (1.8.0_91), the result is the same.

                  请注意,我没有将模块包含为 .jar 库,它是使用以下指令导入的源代码:

                  Note this, that I don't include the module as .jar library, it is source code which is importing with following instruction:

                  include ':app', ':my-module'
                  project(':my-module').projectDir = new File(settingsDir, '../my-module-java')
                  

                  推荐答案

                  知道了,错误是因为我没有在模块本身中指定兼容性选项.这意味着如果您已安装并使用 JDK 8,并且您的 android 项目使用 Java 1.7(默认情况下在 Android SDK 23 及更低版本中)并且它包含一个没有任何使用 Java 1.7 规范的模块,那么该模块将被编译为JDK 8 使用 Java 1.8 语法并且会出现错误,因为它们不兼容并且使用 Java 1.7 的编译器无法解析针对 Java 1.8 且版本为 52 的类文件.

                  Got it, the error was because I didn't specify compatibility options in the module itself. That means if you have installed and using JDK 8 and your android project uses Java 1.7 (which is by default in Android SDK 23 and below) and it has a module included without any specification to use Java 1.7, then that module will be compiled with JDK 8 using Java 1.8 syntax and there will be an error because they are not compatible and compiler that uses Java 1.7 can't parse class files which were targeting Java 1.8 and have the version 52.

                  build.gradle - 此构建文件用于模块级别

                  apply plugin: 'java'
                  
                  buildscript {
                      tasks.withType(JavaCompile) {
                          sourceCompatibility = JavaVersion.VERSION_1_7
                          targetCompatibility = JavaVersion.VERSION_1_7
                      }
                  }
                  
                  dependencies {
                      compile fileTree(include: ['*.jar'], dir: 'libs')
                  
                      // Your libraries here
                  
                  }
                  

                  这篇关于得到“不支持的类文件版本 52.0"在将模块包含到项目中之后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:“你好世界"Android 应用程序尽可能少的文件, 下一篇:Android X:tools:replace 在 line:for 属性中指定,但没有

                  相关文章

                  最新文章

                    <small id='hsHns'></small><noframes id='hsHns'>

                  1. <legend id='hsHns'><style id='hsHns'><dir id='hsHns'><q id='hsHns'></q></dir></style></legend>
                    <tfoot id='hsHns'></tfoot>

                      <i id='hsHns'><tr id='hsHns'><dt id='hsHns'><q id='hsHns'><span id='hsHns'><b id='hsHns'><form id='hsHns'><ins id='hsHns'></ins><ul id='hsHns'></ul><sub id='hsHns'></sub></form><legend id='hsHns'></legend><bdo id='hsHns'><pre id='hsHns'><center id='hsHns'></center></pre></bdo></b><th id='hsHns'></th></span></q></dt></tr></i><div id='hsHns'><tfoot id='hsHns'></tfoot><dl id='hsHns'><fieldset id='hsHns'></fieldset></dl></div>
                      • <bdo id='hsHns'></bdo><ul id='hsHns'></ul>