Package android.os does not exist (when compiling with JDK 11)

Viewed 561

I have started an Android app using Intellij and Gradle. At some point I got the following error message:

error: package android.os does not exist
import android.os.StrictMode;

I have noticed that it works fine when I use JDK 1_8 but fails when I use JDK 11. Does anyone know how to fix this?

It works with:

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

It fails with:

compileOptions {
    sourceCompatibility JavaVersion.VERSION_11
    targetCompatibility JavaVersion.VERSION_11
}
1 Answers
Related