Home > Mobile >  Cordova - How to build and emulate android app on mac os
Cordova - How to build and emulate android app on mac os

Time:04-05

I'm attempting to build a cordova application, starting from following the documentation for the hello world example.

When I build my application for android, it builds successfully, however when running.

cordova run android

I recieve the following error:

BUILD SUCCESSFUL in 2s
48 actionable tasks: 48 up-to-date
Built the following apk(s): 
/Users/ivyjack/Sites/hello/platforms/android/app/build/outputs/apk/debug/app-debug.apk
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=/Users/ivyjack/Library/Android/sdk (recommended setting)
ANDROID_HOME=/Users/ivyjack/Library/Android/sdk (DEPRECATED)
Using Android SDK: /Users/ivyjack/Library/Android/sdk
Command failed with exit code 1: apkanalyzer manifest target-sdk /Users/ivyjack/Sites/hello/platforms/android/app/build/outputs/apk/debug/app-debug.apk
Exception in thread "main" java.lang.IllegalStateException: Cannot locate latest build tools
at com.android.tools.apk.analyzer.AaptInvoker.getPathToAapt(AaptInvoker.java:99)
at com.android.tools.apk.analyzer.AaptInvoker.<init>(AaptInvoker.java:41)
at com.android.tools.apk.analyzer.ApkAnalyzerCli.getAaptInvokerFromSdk(ApkAnalyzerCli.java:278)
at com.android.tools.apk.analyzer.ApkAnalyzerCli.main(ApkAnalyzerCli.java:129)

I have updated my .zshrc file to include my paths:

 #ANDROID SDK
 export ANDROID_HOME=~/Library/Android/sdk
 export ANDROID_SDK_ROOT=~/Library/Android/sdk
 export PATH=${PATH}:${ANDROID_HOME}/tools
 export PATH=${PATH}:${ANDROID_HOME}/platform-tools


 export JAVA_HOME=`/usr/libexec/java_home -v 1.8`

I'm not sure what I am missing to be able to get the cordova application running for android? Any help would be appreciated.

CodePudding user response:

I have encounter the same issue, and resolved by installing gradle

$ brew install gradle

NOTE : if you are using M1 you need additional shell settings for brew (https://mac.install.guide/homebrew/3.html)

  • Related