I am facing issues with my Android project setup in Android Studio, particularly related to Gradle and Java versions. I have tried multiple solutions, but I am still encountering errors. Here is a detailed description of my problem:
Environment:
OS: macOS
Java Version: 22.0.1
Gradle Version: 8.0
Errors and Attempts:
Error 1: Unsupported class file major version 61
kotlin
Copier le code
org.gradle.groovy.scripts.ScriptCompilationException: Could not compile initialization script ‘/private/var/folders/…/ijMapper1.gradle’.
startup failed:
General error during conversion: Unsupported class file major version 61
java.lang.IllegalArgumentException: Unsupported class file major version 61
Solution Attempts:
Tried downgrading Java to version 17 as recommended, but the environment still shows Java version 22.0.1 despite the changes in .zshrc.
.zshrc File Configuration:
bash
Copier le code
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home
export PATH=$PATH:$JAVA_HOME/bin
Restarted the terminal and Android Studio after making changes, but java -version still shows 22.0.1.
Error 2: Namespace Not Specified
vbnet
Copier le code
java.lang.RuntimeException: Namespace not specified. Please specify a namespace in the module’s build.gradle file like so:
Solution Attempts:
Added namespace to build.gradle:
gradle
Copier le code
android {
compileSdkVersion 33
namespace ‘com.example.myapp’
…
}
Error 3: Plugin [id: ‘com.google.gms.google-services’] was not found
python
Copier le code
Plugin [id: ‘com.google.gms.google-services’] was not found in any of the following sources:
gökhan gürbüz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.