Unresolved reference: JavaVersion.VERSION_1_8

﹥>﹥吖頭↗ 提交于 2020-01-13 08:17:08

问题


How to fix the following error?

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

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


回答1:


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

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

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

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

Now it's all work fine.



来源:https://stackoverflow.com/questions/53051923/unresolved-reference-javaversion-version-1-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!