我将 github 模块导入到 Android Studio 和 build.gradle 编译部分。
该模块是 - https://github.com/go-ive/steam-api
每当我尝试运行该应用程序时,都会收到此错误:
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.
我尝试添加这两行并尝试了许多其他选项,但它仍然不起作用。我可以添加一些东西来使这个特定的模块工作吗?谢谢。
build.gradle 看起来像这样(不包括顶部):
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.github.go-ive:steam-api:4.2'
testCompile 'junit:junit:4.12'
}
最佳答案
我读到the project's POM ,并且它使用 Java 8 作为源和目标。您可以联系作者(也许提出 GitHub 问题)并询问 Java 7 兼容性是否可能,但如果该库使用 Java 8 功能(特别是 lambda,这对异步网络代码非常有帮助),那么它可能不实用。
关于java - 是否可以在 android studio 中使用仅 java 的模块?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40066057/