3

I have setup an empty Basic Activity in Android Studio and I have set the following

android {
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_11
        targetCompatibility = JavaVersion.VERSION_11
    }
}

but it seems that the android jar packages are not seen when building

> Task :app:compileDebugJavaWithJavac FAILED
error: package android.annotation does not exist
import android.annotation.SuppressLint;

error: package android.content does not exist
import android.content.Intent;
...

and many other packages from the android.jar file are not seen

Ciccio
  • 189
  • 10
  • [This might help](https://stackoverflow.com/a/54956457/7704650) – emkarachchi Jan 03 '21 at 20:21
  • Didn't work as there are dependencies using the androidx.* package so the compiler errors and says I have to enable it back `Execution failed for task ':app:checkDebugAarMetadata'. > This project uses AndroidX dependencies, but the 'android.useAndroidX' property is not enabled. Set this property to true in the gradle.properties file and retry. The following AndroidX dependencies are detected: androidx.fragment:fragment:1.2.4, androidx.constraintlayout:constraintlayout-solver:2.0.4 ` – Ciccio Jan 03 '21 at 20:26
  • for `androidX` problem [this](https://developer.android.com/jetpack/androidx/migrate) could be helpfull – anatoli Jan 03 '21 at 21:47
  • This is not an issue with androidX. All the packages from android.jar are not seen when trying to compile with jdk11 I believe due to the new introduced modularity in jdk9. Try to create new project with an empty activity and try to compile with jdk11 ... And you will get a lot of errors saying that android.* Could not be found – Ciccio Jan 04 '21 at 18:06
  • 1
    @Ciccio did you find out how to fix the issue? I'm experiencing the same problem – Adriana Pineda Feb 09 '21 at 19:52

0 Answers0