Some times ago, I tried to build my ionic project on a macOS by:
- ionic cap build android
- ionic cap build ios
Similar to this question, when I run above commands I got:
[ERROR] Unable to find command: cap build android (or ios)
ionic cap - Capacitor functionality
These commands integrate with Capacitor, Ionic's new native layer project which
provides an alternative to Cordova for native functionality in your app.
Learn more about Capacitor:
- Main documentation: https://ion.link/capacitor
Usage:
$ ionic cap <command> [<args>] [--help] [--verbose] [--quiet] [--no-interactive]
[--no-color] [--confirm] [options]
add ............................. Add a native platform to your Ionic project
copy ............................ Copy web assets to native platforms
open ............................ Open the IDE for a given native platform project
run ............................. (beta) Run an Ionic project on a connected device
sync ............................ Sync (copy + update) an Ionic project
update .......................... Update Capacitor native platforms, install Capacitor/Cordova plugins
I considered all the given answers and points for that question, e.g., I ensured:
- capacitor is installed
- android and ios platforms are added
- uninstalled and installed ionic and ionic/cli and ionic/core.
None of the above solved the problem. Then, I started to use ionic cap run android (or ios)
and everything was working perfectly.
However, today, I tried to run/build an old code with this command on the macOS, and I got some errors related to sdk version.
Then, I build the same code on another system on which ionic cap build android
works, and the error was gone.
To see what is the difference between the two systems, first, I checked all parameters, including min, compile, and target sdk, gradle version, gradle variables and so on, all were the same on both systems.
Then I got curious to see how is the file that shows the error on the other system, and I noticed that, this file is not even generated on the other system (the error is shown inInternalUtils
in /node_modules/@capacitor/android/capacitor/src/main/java/com/getcapacitor/util
). Thus, I think the problem is in ionic cap run android
(Am I right?).
So I thought it is time to finally get ionic cap build android
working on the macOS!
Does any one have any idea how to get it working? Thanks in advance.