java - 是否可以在 android studio 中使用仅 java 的模块?

标签 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'
}

最佳答案

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

关于java - 是否可以在 android studio 中使用仅 java 的模块?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40066057/

相关文章:

android - Kotlin 对 @ColorInt Java 注释的支持

java - 切换Activity后Fragment Activity消失

java - Android 梯度错误 : package does not exist

android - 使用 Dagger2、Room 和数据绑定(bind)时出错

android - 更新到 Android Studio,现在收到 AAPT : error: resource attr/type not found error for Navigation

java - POJO的getters和setters有必要吗

java - 识别输入来自嵌套列表中的特定列表

android - 用于包装内容的对话框 Activity

java - String.toLowerCase 中的 StackOverflowError

java - 在JAVA中组合字符和字符串的正则表达式