3

I am wotking 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 achive 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 below 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--

enter image description here

I goolged 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

  • Important: I am using Android-Studio Version 4.1.2 and MacBook with macOS Big Sur

Also, please let me know in-case any other details required. Thank you!

Dnyanesh M
  • 1,349
  • 4
  • 18
  • 46
  • what is your gradle-jdk version? File -> Settings -> Build, Execution, Deployment -> Select your gradle project. – Starbax Feb 22 '22 at 15:01

1 Answers1

1

It was solved by changing the android gradle plugin version to 7.0.2.

김종민
  • 11
  • 1