Reputation: 91
Cordova doesn't find "build tools" for Android platform. But it's installed.
I don't understand what is wrong. I read a lot of posts on this kind of issues but without result.
When I try to build cordova app I have this error:
$ cordova build android
Checking Java JDK and Android SDK versions
ANDROID_HOME=undefined (recommended setting)
ANDROID_SDK_ROOT=/Users/ja/Library/Android/sdk (DEPRECATED)
Using Android SDK: /usr/local/Caskroom/android-platform-tools/35.0.1
BUILD SUCCESSFUL in 989ms
1 actionable task: 1 up-to-date
Subproject Path: CordovaLibSubproject Path: app
FAILURE: Build failed with an exception.
* Where:Script '/Users/ja/Documents/works/stellantis/tablets-app/hello/platforms/android/CordovaLib/cordova.gradle' line: 73
* What went wrong:
A problem occurred evaluating script.
> No installed build tools found. Please install the Android build tools version 34.0.0.
2 questions :
Why ANDROID_HOME is undefined ?
Why cordova use /usr/local/Caskroom/android-platform-tools/35.0.1 and not /Users/ja/Library/Android/sdk ?
I'm on Mac Sonoma 14.5
$ cordova -v => 12.0.0 ([email protected])
I have a fresh install of Android Studio. In the "Tools" menu:
There is only SDK version 14 installed (hiding or not obsolete packages) into Android Studio.
The path: /Users/ja/Library/Android/sdk
I use ZSH ( $ echo $SHELL => /bin/zsh )
Files ~/.bash_profile and ~/.zshrc contain :
export ANDROID_HOME=~/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools
As explained on https://developer.android.com/tools/variables
I try $ source ~/.bash_profile and $ source ~/.zshrc
Build Tools is present: /Users/ja/Library/Android/sdk/build-tools/34.0.0
No suggestion during StackOverflow review works.
What's wrong ?
Tell me if I forgot something to show.
Thank You.
Upvotes: 2
Views: 981
Reputation: 15759
I'm using Mac M3, I solved this issue as follows:
cd ~
sudo nano .zshenv
Then I added 3 lines
export ANDROID_HOME=~/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/pla$
export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jbr/Contents/Home
Then I saved using ^x then Y I made sure that the file was propagated
echo $JAVA_HOME
echo $ANDROID_HOME
Then, I closed the terminal totally, opened a new terminal, and tried the last step again to make sure that the .zshenv
now applies to any new terminal.
I would like to thank @djo because I got some ideas from him, but didn't work as is.
The Cordova command now works fine now.
Upvotes: 0
Reputation: 639
I was facing the same issue.
After hours of trying to restart Android Studio, removing the platform, invalidating caches, etc., what actually worked was to remove the build tools from the Android Studio SDK manager and install them again.
So I invalidated the cache just to be sure, restarted Android Studio again and everything worked as expected.
Upvotes: 0
Reputation: 29
Update your platforms\android\cdv-gradle-config.json "SDK_VERSION":35 and "MIN_BUILD_TOOLS_VERSION":"35.0.0"
Upvotes: 0
Reputation: 91
What just worked in my case, put:
export ANDROID_HOME=~/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools
In the files ~/.bash_profile and ~/.zshrc
$ source ~/.bash_profile
$ source ~/.zshrc
Exit the terminal completely and then relaunch it. The cordova command now works fine.
Upvotes: 0