joreilly / PeopleInSpace

Kotlin Multiplatform sample with SwiftUI, Jetpack Compose, Compose for Wear, Compose for Desktop, and Compose for Web clients along with Ktor backend.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot build the project - An exception occurred applying plugin request [id: 'com.android.application']

safaiyeh opened this issue · comments

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/safaiyeh/code/PeopleInSpace/app/build.gradle.kts' line: 1

* What went wrong:
An exception occurred applying plugin request [id: 'com.android.application']
> Failed to apply plugin 'com.android.internal.application'.
   > Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
     You can try some of the following options:
       - changing the IDE settings.
       - changing the JAVA_HOME environment variable.
       - changing `org.gradle.java.home` in `gradle.properties`.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.8-rc-4/userguide/command_line_interface.html#sec:command_line_warnings

https://android-developers.googleblog.com/2020/12/announcing-android-gradle-plugin.html

"With AGP 7.0.0-alpha01 we are changing the minimum required Java programming language version to Java 11."

This is needed as Jetpack Compose requires use of Canary version of Android Studio.

Ah interesting. I'm used to ignoring the Java upgrade warning - will upgrade

https://android-developers.googleblog.com/2020/12/announcing-android-gradle-plugin.html

"With AGP 7.0.0-alpha01 we are changing the minimum required Java programming language version to Java 11."

This is needed as Jetpack Compose requires use of Canary version of Android Studio.

Can you please tell me, how to do that on Ubuntu 20.04 ?

@piyushpradhan I think all you need to do is first go to the:

  1. Android Studio menu -> Preferences -> Build, Execution, Deployment
  2. In the gradle projects section, select: Gradle JDK version drop down menu
  3. It will show all the JDKs you have installed on your device // See attached image bottom right drop down menu.
  4. Select JDK 11.

Done, now you should be able to build without issues.

Or if you are using CLI to build, then change the ~/.zshrc ( or bash equivalent file for Ubuntu, I am using MacOS 11 so it is Zsh here, you should be having Bash on your device) to JDK11. After your change to the Zsh/Bash resource file, save it and then execute command:

  • $ source ~/.zshrc // to update change
  • $ java -version // to check java version

Sample output java version:

openjdk version "11.0.8" 2020-07-14 LTS
OpenJDK Runtime Environment Corretto-11.0.8.10.1 (build 11.0.8+10-LTS)
OpenJDK 64-Bit Server VM Corretto-11.0.8.10.1 (build 11.0.8+10-LTS, mixed mode)

image

Note:
I am using MacOS 11.2.1, Android Studio Artic Fox, 2020.3.1, Gradle Version 7.0.2

image

Thank you ! It worked

@piyushpradhan I think all you need to do is first go to the:

  1. Android Studio menu -> Preferences -> Build, Execution, Deployment
  2. In the gradle projects section, select: Gradle JDK version drop down menu
  3. It will show all the JDKs you have installed on your device // See attached image bottom right drop down menu.
  4. Select JDK 11.

Done, now you should be able to build without issues.

Or if you are using CLI to build, then change the ~/.zshrc ( or bash equivalent file for Ubuntu, I am using MacOS 11 so it is Zsh here, you should be having Bash on your device) to JDK11. After your change to the Zsh/Bash resource file, save it and then execute command:

  • $ source ~/.zshrc // to update change
  • $ java -version // to check java version

Sample output java version:

openjdk version "11.0.8" 2020-07-14 LTS
OpenJDK Runtime Environment Corretto-11.0.8.10.1 (build 11.0.8+10-LTS)
OpenJDK 64-Bit Server VM Corretto-11.0.8.10.1 (build 11.0.8+10-LTS, mixed mode)

image

Note: I am using MacOS 11.2.1, Android Studio Artic Fox, 2020.3.1, Gradle Version 7.0.2

Thank you. It works now.