I have created a new KMM project and I get red errors in all Gradle files
kdoctor:
[v] System
OS: macOS (12.5.1)
CPU: Apple M1 Pro
[v] Java
Java (openjdk version "17.0.4" 2022-07-19 LTS)
Location: /Library/Java/JavaVirtualMachines/openjdk17-corretto/Contents/Home/bin/java
JAVA_HOME=/Library/Java/JavaVirtualMachines/openjdk17-corretto/Contents/Home
* Note that, by default, Android Studio uses bundled JDK for Gradle tasks execution.
Gradle JDK can be configured in Android Studio Preferences under Build, Execution, Deployment -> Build Tools -> Gradle section
[v] Android Studio
Android Studio (2021.2)
Location: /Users/ahmedhnewa/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/212.5712.43.2112.8815526/Android Studio.app
Bundled Java: openjdk 11.0.12 2021-07-20
Kotlin Plugin: 212-1.7.10-release-333-AS5457.46
Kotlin Multiplatform Mobile Plugin: 0.3.3(212-1.7.0-RC-release-217-IJ)-104
[v] Xcode
Xcode (13.4.1)
Location: /Applications/Xcode.app
[x] Cocoapods
ruby (ruby 2.6.8p205 (2021-07-07 revision 67951) [universal.arm64e-darwin21])
* System ruby is currently used
CocoaPods is not compatible with system ruby installation on Apple M1 computers.
Please install ruby 2.7 via Homebrew, rvm, rbenv or other tool and make it default
ruby gems (3.0.3.1)
cocoapods (1.11.3)
* cocoapods-generate plugin not found
Get cocoapods-generate from https://github.com/square/cocoapods-generate#installation
Failures: 1
KDoctor has diagnosed one or more problems while checking your environment.
Please check the output for problem description and possible solutions.
I created a project with regular ios distribution framework. I have even tried to install ruby 2.7 using homebrew and I add the path to env and the error is still the same so I revert all the changes back
settings.gradle.kts:
pluginManagement {
repositories {
google()
gradlePluginPortal()
mavenCentral()
}
}
rootProject.name = "DemoKMM"
include(":androidApp")
include(":shared")
build.gradle.kts:
buildscript {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10")
classpath("com.android.tools.build:gradle:7.2.2")
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
}
I have tried too many solutions and I already read the documentation and nothing work.
I just update Android Studio to Electric Eel (2022.1.1) and KMM Plugin and it solved
Edit 2:
The issue came again to me,
I have fixed the issue by removing android studio and all its files, including ~/.android, ~/.gradle
so even all IDE that uses gradle, so I just removed the cache folder of .gradle
I also removed Android SDK and everything
You can use something like App Cleaner even though I don't really trust the app since it is not open source
drag and drop android studio into it, if you install Android Studio using JetBrains toolbox, please find the path of it and open it in the toolbox and drag and drop
before clicking uninstall, click it from JetBrains toolbox first and then uninstall it from the app cleaner
and do a clean install, just install the KMM plugin without anything, like the Flutter plugin and all that stuff
if you want to manually delete everything using the terminal, see this on Stackoverflow
while I did fix the issue, I still don't know what exactly was the issue,
and I need to know so I make sure it will not happen again,
please if you know, share your thought