本文介绍了未解决的参考:JavaVersion.VERSION_1_8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何解决以下错误?

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

Android Studio->文件->项目结构->模块-> 未解决的参考:JavaVersion.VERSION_1_8

Android Studio --> File --> Project Structure --> Modules --> Unresolved reference: JavaVersion.VERSION_1_8

推荐答案

我在根build.gradlebuildscript部分中添加了ext.java_version变量

I added to the buildscript section of the root build.gradle the ext.java_version variable

buildscript {
    ...
    ext.java_version = JavaVersion.VERSION_1_8
    ...
}

,然后将模块的build.gradle JavaVersion.VERSION_1_8更改为java_version

and changed in the module's build.gradle JavaVersion.VERSION_1_8 to java_version

android {
    ...
    compileOptions {
        sourceCompatibility java_version
        targetCompatibility java_version
    }
    ...
}

现在一切正常.

这篇关于未解决的参考:JavaVersion.VERSION_1_8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 10:54