I was working on a project few months back, that time it was working, now I cloned the repo again and did all the steps like
npm install
and then npx expo run:android
but I get this error
and even after uninstalling expo-modules-core
I get the error
> Configure project :expo-modules-core
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* Where:
Script 'C:\Users\princ\Downloads\freelancing\prince\tradespoto-admin\node_modules\expo-modules-autolinking\scripts\android\autolinking_implementation.gradle' line: 326
* What went wrong:
A problem occurred evaluating project ':expo'.
> A problem occurred configuring project ':expo-modules-core'.
> Failed to notify project evaluation listener.
> SDK location not found. Define a valid SDK location with an ANDROID_HOME environment variable or by setting the sdk.dir path in your project's local properties file at 'C:\Users\princ\Downloads\freelancing\prince\tradespoto-admin\android\local.properties'.
> Could not get unknown property 'release' for SoftwareComponentInternal set of type org.gradle.api.internal.component.DefaultSoftwareComponentContainer.
* 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.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':expo'.
> compileSdkVersion is not specified. Please add it to build.gradle
* 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
BUILD FAILED in 13s
10 actionable tasks: 10 up-to-date
Error: C:\Users\princ\Downloads\freelancing\prince\tradespoto-admin\android\gradlew.bat exited with non-zero code: 1
So the main reason for this issue is that ANDROID_HOME variable is not set and nor is the local.properties file present in android folder.
For me personally, it got fixed after putting local.properties file because in Windows, setting the variable doesn't work.
So in local.properties file put this.
sdk.dir={path to sdk}
Note - If the path says folder name is "Sdk" still use "sdk" only, then only it worked for me.
In Mac and in Linux, you can do by setting the variable in
For mac, set in ~/.zshrc
export ANDROID_HOME=$HOME/Library/Android/sdk
For linux, do same way, just path will change and do it the terminal profile you are using.
[EDIT] If changes are not working, and you still get error. One time I fixed it by doing this.