I am working on multi-module Android project, currently this project is using Java 8 and as part of requirement I am upgrading this project to Java 11. Below is what I tried so far to achieve the same-
1] Installed JDK-11 and set JDK location pointing to java-11 (i.e. File --> Project Structure --> SDK Location --> JDK Location)
2] As it is multi-module project, I did the following chages in all module-level build.gradle files-
android{
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '11'
}
}
Then I am able to Sync and Build the project successfully, but when I'm trying to run the project, I'm getting "error: package android.view does not exist" error and some other related errors, please check below screenshot for more details--

I googled this error and found couple of related posts on Stackoverflow (below are the links) but haven't found any concrete solution yet.
1] error: package android.view does not exist
2] Migrating Java 8 project to Java 11
3] android + sourceCompatibility JavaVersion.VERSION_11: error: package android.os does not exist
Please let me know in-case any other details required. Thank you!
It was solved by changing the android gradle plugin version to 7.0.2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With