Home > Blockchain >  Auto-build stuck on Android studio after update
Auto-build stuck on Android studio after update

Time:09-23

I updated my Android studio to the latest version 2020.3.1, including Android Gradle Plugin v7.0.2 and Gradle v7.2. After some configuration nightmare (as always with AS, no surprises there), I managed to make my project compile and run, everything seemed smooth. But I realized not long after that the "auto-build" feature is actually stuck. Basically my AS is not auto building while I am coding, meaning that I cannot even see basic error like typos and such until I actually build my project with CTRL B.

I can see that I have an error in the auto-build section telling me: Error:java: warning: source release 11 requires target release 11

I tried pretty much all JDK possible with different config, from 1.8 to 17. All of them trigger that error...

Here is how it looks like: enter image description here

I am getting desperate at that point, I'll take any suggestion in order to fix that issue.

CodePudding user response:

Invalidate Cache clears project structure-related information (only) cached by Android studio. Please note that this cache is different from "Build Cache" and "Gradle cache" briefly explained below.

Build Cache - stores certain outputs that the Android plugin for Gradle generates when building your project e.g. unpackaged AARs and pre-dexed remote dependencies. Build cache is enabled by default in recent plugins (2.3.0 ).

Build Cache path: C:\Users[User_Name].android\build-cache\gradleVersion

Here version value is driven by value defined in build.gradle file in your project. e.g. classpath "com.android.tools.build:gradle:$gradleVersion" Invalidate Cache has no impact on Build Cache. It can be cleared using "gradlew cleanBuildCache" command instead.

Gradle Cache - maintains Download Dependencies.

Gradle Cache path: C:\Users[user_name].gradle\caches\modules-2\files-2.1 [Windows] ~/.gradle/caches/modules-2/files-2.1 [Mac]

Also, as mentioned by @anurag, Clean Project has no relation to Build Cache.

CodePudding user response:

You can

  • try modifying the target bytecode & project bytecode in File | Settings | Build, Execution, Deployment | Compiler | Java Compiler -> set target bytecode & project bytecode version to 11.

  • check in File | Project Structure | Modules that all of your modules are registered as java 11

  • check in File | Project Structure | Modules for each module, in the Dependencies tab, Module SDK is registered as java 11

  • check in File | Project Structure | Platform settings | SDKs that only one JDK is present (to avoid potential conflict)

  • check in File | Settings | Build, Execution, Deployment | Build Tools | Gradle that Gradle JVM is Java 11

  • delete your Android Studio and everything related to it (setting, cache, profile) on your computer and reinstall it

  • Related