可以在android studio中使用仅限java的模块吗?

时间:2016-10-16 01:56:23

标签: java android gradle

我将一个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'
}

1 个答案:

答案 0 :(得分:1)

我读了the project's POM,它使用Java 8作为源和目标。您可以联系作者(可能会引发GitHub问题)并询问是否可以兼容Java 7,但如果库使用Java 8功能(特别是lambda,这对异步网络代码非常有用),那么它可能不实用。