Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android studio中库的Java 1.7兼容性_Java_Android_Build.gradle - Fatal编程技术网

android studio中库的Java 1.7兼容性

android studio中库的Java 1.7兼容性,java,android,build.gradle,Java,Android,Build.gradle,我想在我的android studio项目中使用库,但当我使用gradle将它添加到项目中时,它会显示以下错误 Error:Error converting bytecode to dex: Cause: Dex cannot parse version 52 byte code. This is caused by library dependencies that have been compiled using Java 8 or above. If you are using the '

我想在我的android studio项目中使用库,但当我使用gradle将它添加到项目中时,它会显示以下错误

Error:Error converting bytecode to dex: Cause: Dex cannot parse version 52 byte code. This is caused by library dependencies that have been compiled using Java 8 or above. If you are using the 'java' gradle plugin in a library submodule add targetCompatibility = '1.7' sourceCompatibility = '1.7' to that submodule's build.gradle file.

这似乎是因为Java1.7的兼容性,但我不知道如何修复它。Android studio建议将targetCompatibility='1.7'sourceCompatibility='1.7'添加到该子模块的build.gradle中,但如何将其添加到gradles依赖项部分?

您应该使用
VERSION\u 1\u 8
而不是
VERSION\u 1\u 7

安装

你应该加上这个

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
FYI

使用前请阅读

要为项目启用Java 8语言功能和Jack,请在模块级build.gradle文件中输入以下内容:

android {
  ...
  defaultConfig {
    ...
    jackOptions {
      enabled true
    }
  }
  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }
}

清理重建运行您应该使用
版本1\u 8
而不是
版本1\u 7

安装

你应该加上这个

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
FYI

使用前请阅读

要为项目启用Java 8语言功能和Jack,请在模块级build.gradle文件中输入以下内容:

android {
  ...
  defaultConfig {
    ...
    jackOptions {
      enabled true
    }
  }
  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }
}

清理重建运行版本52实际上是Java 8。 该库是在没有与Java 7兼容的情况下编译的,因此如果您的目标是Java 7或更低版本,则无法使用该库


我看到他们的GitHub上有一个关于它的链接。仅此版本可能有问题,因此您可以尝试使用以前的版本,直到他们解决此问题。

版本52实际上是Java 8。 该库是在没有与Java 7兼容的情况下编译的,因此如果您的目标是Java 7或更低版本,则无法使用该库


我看到他们的GitHub上有一个关于它的链接。仅此版本可能有问题,因此您可以尝试使用以前的版本,直到他们解决此问题。

您好,是的,这个问题正是我所问的。我不能下载并用java 7重新编译它吗?或者把我的项目分成子模块之类的?是的,你可以这样做。只要确保它没有任何Java8特性,比如lambdas,否则编译就会失败。在这种情况下,您还需要重构代码。但我认为如果你尝试1.0.0版而不是1.0.1版,它也会工作。嗨,是的,这个问题正是我所问的。我不能下载并用java 7重新编译它吗?或者把我的项目分成子模块之类的?是的,你可以这样做。只要确保它没有任何Java8特性,比如lambdas,否则编译就会失败。在这种情况下,您还需要重构代码。但我认为如果你尝试1.0.0版而不是1.0.1版,它也会工作。使用java 8有什么缺点吗?我的意思是,现在与java 7一起工作的其他依赖是否面临任何问题等?@MajidHojati没有遇到任何问题yetIs使用java 8有任何缺点吗?我的意思是,现在与java 7一起工作的其他依赖是否面临任何问题等等?@MajidHojati还没有遇到任何问题