Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting "error: package android.view does not exist" error while migrating my existing Android Project from Java 8 to Java 11

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

enter image description here

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

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

Please let me know in-case any other details required. Thank you!

like image 858
Dnyanesh M Avatar asked May 17 '26 11:05

Dnyanesh M


1 Answers

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

like image 175
김종민 Avatar answered May 20 '26 02:05

김종민



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!