Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unresolved reference: JavaVersion.VERSION_1_8

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

enter image description here

like image 996
Alexander Savin Avatar asked Oct 29 '18 18:10

Alexander Savin


1 Answers

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.

enter image description here

like image 56
Alexander Savin Avatar answered Nov 06 '22 03:11

Alexander Savin