MAC - Cordova error after installing Android Studio - android

On Mac os - Cordova stoped working after installing Android Studio (4.4.1)
NOTE: it was working previous to the installation
With the following errors:
The command "android" failed. Make sure you have the latest Android SDK installed, and the "android" command (inside the tools/ folder) is added to your path.
And (After the first one was solved)
You may not have the required environment or OS to build this project

The android PATH changes and was not updated by the cordova, I had to do:
update PATH env var
touch ~/.bash_profile; open ~/.bash_profile
add the lines:
export ANDROID_SDK="/Users/%USR%/Library/Android/sdk"
export ANDROID_HOME="$ANDROID_SDK"
export ANDROID_PLATFORM_TOOLS="$ANDROID_SDK/platform-tools"
export PATH="${PATH}:$ANDROID_HOME/tools:$ANDROID_PLATFORM_TOOLS"
update local.properties under platforms/andorid and platforms/android/CordovaLib (line 10) to
sdk.dir=/Users/%USR%/Library/Android/sdk
where %USR% is your user name

Related

Cordova build android "no android build tools"

So im running into a probelm with cordova
I am running a linux machine trying to build a cordova app how ever,
When i try
$ Cordova build android
I get a the following error
No installed build tools found. Install the Android build tools version 19.1.0 or higher.
How ever i do have it installed
And i have edit my .bashrc & .profile to reflect the changes needed for
$ANDROID_HOME
Am i missing something?
This seems to be an error of the paths:
You need to define paths as:
vim .bashrc
Add the following lines:
export ANDROID_HOME=/Users/user/Software/Android
export PATH=${PATH}:/Users/user/Software/Android/tools
export PATH=${PATH}:/Users/user/Software/Android/platform-tools
Note: When you edit the environment variables you need to reload them.
$source .bashrc //for ubuntu
$source .bash_profile //for mac
Type the following command:
$android
in terminal and hit enter.
If everything is working fine you can try running
$cordova build android
This seems to be a duplicate of the question: questions/31190355/ionic-build-android-error-no-installed-build-tools-found-please-install-the

cordova requirements android target not installed cmd: Command failed with exit code 1 Error output:

C:\Users\GINOM HANGSHING\hello>cordova requirements
Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: not installed
cmd: Command failed with exit code 1 Error output:
'android' is not recognized as an internal or external command,
operable program or batch file.
Gradle: installed C:\Program Files\Android\Android Studio\gradle\gradle-3.2\bin\gradle
Error: Some of requirements check failedenter image description here
Try to update your android platform by
C:\Users\GINOM HANGSHING\hello>cordova platform update android --save
Add System variable, Path. Add "\tools" directory (in addition of "\platform-tools") of your Android SDK folder. There "android.bat" is located.
Restart any open terminals.
How to check Android SDK folder: Android SDK location
If you do not find a \tools folder in your Android SDK folder, you can either try reinstalling your Android SDK or downloading and extracting the tools without the IDE from the links below (Be sure to have read and agreed with the terms of service before downloading any of the command line tools)
Windows no installer: https://dl.google.com/android/repository/sdk-tools-windows-4333796.zip
MacOSX: https://dl.google.com/android/repository/sdk-tools-darwin-4333796.zip
Linux: https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
This is how I solved the issue on my machine.
(Deepin 20 community)
After updating my android platform by running the following commands:
cordova platform rm android
and
cordova platform add android
I configured my environment variables and path as follows:
export ANDROID_SDK_ROOT="path-to-android-studio/Sdk"
export JAVA_HOME="/usr/lib/jvm/jdk1.8.0_301/"
export PATH="$PATH:$ANDROID_SDK_ROOT/platform-tools"
export PATH="$PATH:$ANDROID_SDK_ROOT/tools"
export PATH="$PATH:$ANDROID_SDK_ROOT/tools/bin"
export PATH="$PATH:$ANDROID_SDK_ROOT/emulator"
That solved the problem

Cannot build ionic project due to ANDROID_HOME path issues

I use linux mint. I set the path on ~/.bash_profile like:
export ANDROID_HOME=/home/mss/android-sdks
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
When I build ionic project on android :-
lenovo-g50 ~/IONIC/apps $ cordova run android
Running command:
/home/mss/IONIC/apps/hooks/after_prepare/010_add_platform_class.js /home/mss/IONIC/apps
Add to body class: platform-android
Error: Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable.
in windows OS
set PATH=%PATH%;C:\Users\userName\AppData\Local\Android\android-sdk\tools;C:\Users\userName\AppData\Local\Android\android-sdk\platform-tools
IN mac
export PATH=${PATH}:/Users/userName/Documents/android-sdk-mac_x86/platform-tools:/Users/userName/Documents/android-sdk-mac_x86/tools
You have to download the sdk. I think your environment variable are set properly, but you don't have the required SDK. type android -v in your console and it start the SDK manager or you can start it manualy in ANDROID_HOME directory. You need to install several build tools and in minimum one SDK Platform.

PhoneGap: Unable to Create Android App using Terminal

I try to create an android app using PhoneGap on my Mac. But, I only can create the app (hello) and couldn't create the Android platform for it using $ cordova platform add android command.
The error message I get is: [Error: The command android failed. Make sure you have the latest Android SDK installed, and the android command (inside the tools/ folder) added to your path. Output: ]
The screenshot:
I try to put the PATH in the bash profile file using touch ~/.bash_profile; open ~/.bash_profile method, but it still didn't work.
How to solve this problem?
try this one
install android sdk in /Applications then rename the andoid sdk folder's name to android_sdk
create .bash_profile in this directory, /Users/zulhilmizainudin
open .bash_profile then type this command
export PATH=/Applications/android_sdk/tools:$PATH
export ANDROID="/Applications/android_sdk/tools"
Save .bash_profile file
type android command in your terminal

Cordova and setting Android using command line

I am trying to migrate my existing project from cordova 2.1 to the latest, 3.1 which can be installev vía command line,
I already have the Android SDK installed,
So:
sudo npm install -g cordova // All good
cordova create hello com.example.hello HelloWorld // All good
cordova platform add android // Then it fires:
Checking Android requirements...
[Error: The command `android` failed. Make sure you have the latest Android SDK installed, and the `android` command (inside the tools/ folder) added to your path. Output: ]
So I installed Macports and tried:
sudo port install android
Which logs:
Warning: All compilers are either blacklisted or unavailable; defaulting to first fallback option
Warning: Xcode does not appear to be installed; most ports will likely fail to build.
---> Cleaning android
---> Scanning binaries for linking errors: 100.0%
---> No broken files found.
Any idea what am I missing here?
It's work cordova Android for MAC 1000000000%. I fought solution and now i'm working try this #Toni Michel Caubet. I will happy to share my Answer.
STEPS:
Open Your Terminal and followed by,
touch ~/.bash_profile
open ~/.bash_profile
PATH="/Users/System-Name/Documents/android-sdk-macosx/sdk/tools:/Development/android-sdk-macosx/sdk/platform-tools:$PATH" (This is Android SDK Location to stored in My system )
4.Save the file and quit the text editor.
5.Execute your .bash_profile to update your PATH:
source ~/.bash_profile
if you want to see your environment path:
7.In your terminal type: set
After you can see like
8.As far as your made it very correct. After your enter command like cordova platform add android. you get following error. because Java SDK doesn't too set environment PATH.
9.open ~/.bash_profile. Add JAVA_HOME value
10.You can see your environment like STEP 7 set. You should be able see:
11.Successfully created environment now you can create Android project with Cordova or PhoneGap
When you installed the Android SDK, it will come with a bunch of folders, like build-tools, platform-tools, tools, and some others. You need to add platform-tools and tools to your main $PATH environment variable.
See the docs here about how to add things to your PATH for whichever system you are on (Windows or Mac): http://cordova.apache.org/docs/en/3.1.0/guide_platforms_android_index.md.html#Android%20Platform%20Guide
Here is how you would edit the $PATH on Windows:
Click on the Start menu in the lower-left corner of the desktop,
right-click on Computer, then click Properties.
Click Advanced System Settings in the column on the left.
In the resulting dialog box, press Environment Variables.
Select the PATH variable and press Edit.
Append the following to the PATH based on where you installed the
SDK, for example: ;C:\Development\adt-bundle\sdk\platform-tools;C:\Development\adt-bundle\sdk\tools
Save and close both dialogs.
To install the cordova command-line tool, follow these steps:
First of all go through the Cordova Document
For Cordova command-line tools to work, you need to include the SDK's tools and platform-tools directories in your PATH environment. On Mac, you can use a text editor to create or modify the ~/.bash_profile file, adding a line such as the following, depending on where the SDK installs:
export PATH=${PATH}:/Development/adt-bundle/sdk/platform-tools:/Development/adt-bundle/sdk/tools
Next Steps:
Download and install Node.js from Here. Following installation, you should be able to invoke node or npm on your command line.
Install the cordova utility. In Unix(Mac), prefixing the additional sudo command may be necessary to install development utilities in otherwise restricted directories:
For Mac $ sudo npm install -g cordova
once successful installation of cordova is done ,now you can create your application
across all the platforms.
Create the Cordova Application
Go to the directory where you maintain your source code, and run a command such as the following:
$cordova create hello com.example.hello CordovaDemo
hello is the directory where you want to create your application
com.example.hello is the package name
CordovaDemo is the name of the Application
Once Successful creation of your project, some file will be created inside the directory i.e hello
Add Platforms
All subsequent commands need to be run within the project's directory, or any subdirectories within its scope:
$ cd hello
Now you need to specify a set of target platforms, Supported OS for Mac
$ cordova platform add android
plz tell me if you are still having problem.
[Error: The command `android` failed. Make sure you have the latest Android SDK installed, and the `android` command (inside the tools/ folder) added to your path. Output: ]
You just need to install the Latest version of Android i.e 4.3
Go to SDK Manager and install the latest SDK Platform.
And try run the command again.
Hope this will help you.
Here it solved my issue:
into the terminal.
touch ~/.bash_profile (create a bash profile)
open ~/.bash_profile (opening a bash profile)
in your opened file, please type the following, Make sure that you have given the correct path, in case you find it difficult to find your directory in which your Android SDK is installed , search into your terminal with ls -l.
PATH="/Users/System-Name/Documents/android-sdk-macosx/sdk/tools:/Development/android-sdk-macosx/sdk/platform-tools:$PATH"
[Let me clarify first that, this is windows specific suggestion, answer]
For particular cordova version there corresponds particular android API
So,
First check out version of cordova with following command:
$ npm cordova -v
In my case cordova version was 1.4.28 , which corresponds to Android API 19
So the bottom line is don't waste time in downloading all "SDK Platforms"
instead just download corresponding Android API for concerned cordova version...
Hope this help....!!!

Categories

Resources