Reputation: 7581
When using the JDK 11 target, then I get this error:
error: package android.app does not exist
I saw a solution to upgrade to the 'Canary' AS version. I prefer to use the beta or stable Android Studio version. I have updated it regularly. Not planning a major change for just an upgrade.
So, this works well: even with an Android Studio "Project settings" and "JDK" with "JDK 11".
When the build.gradle has these compile options, everything works fine.
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
This gives the mentioned errors:
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
My build.grade project file is:
buildscript {
repositories {
mavenCentral()
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'org.ajoberstar:grgit:3.3'
}
}
allprojects {
repositories {
maven { url "https://jitpack.io" }
google()
}
}
Parts of my build.grade module file is:
apply plugin: 'com.android.application'
repositories {
mavenCentral()
maven { url "https://jitpack.io" }
google()
}
How can I build normally using the (Oracle) JDK 11 compiler?
Upvotes: 3
Views: 13342
Reputation: 7581
Just receive the Android Studio / Gradle 7 upgrade.
Everything is working right now!
compileOptions { sourceCompatibility JavaVersion.VERSION_11 targetCompatibility JavaVersion.VERSION_11 }
Upvotes: 8