Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

avdmanager: Command failed with exit code 1 cordova

i just started to make my first native cordova app from cordova official tutorial, and when I run

ayam@laptop:~/Documents/learn/hello$ cordova requirements

Requirements check results for android:

Java JDK: installed 1.8.0
Android SDK: installed true
Android target: not installed 
*** avdmanager: Command failed with exit code 1
Gradle: installed /usr/local/gradle-3.5/bin/gradle
Error: Some of requirements check failed

I got avdmanager: Command failed with exit code 1

like image 739
Netizen ID Avatar asked Jul 13 '17 14:07

Netizen ID


2 Answers

This problem has possibly 3 origins:

  1. Android tools path settings
  2. JAVA installation
  3. JAVA_HOME path settings

I have explained how to solve all of these on macOS below (Windows might be slightly different)

1. Android tools might not be added with the correct path:

I solved it by doing this in macOS terminal:

PATH=$PATH:$HOME/Library/Android/Sdk/emulator
PATH=$PATH:$HOME/Library/Android/Sdk/tools
PATH=$PATH:$HOME/Library/Android/Sdk/tools/bin
PATH=$PATH:$HOME/Library/Android/Sdk/platform-tools
export ANDROID_HOME=$HOME/Library/Android/

These are all the required path variables by Cordova.

Important:
Make sure that there is a folder called /Android/ inside your user folder inside Library!

It used to be installed directly to the user folder instead of in Library so therefor the confusion.

2. JAVA might be missing or the wrong version:

You need to use JAVA SE v 1.8 for Cordova to work.
Do this in the terminal:

/usr/libexec/java_home -V

and check if that version is available or not. If not you can research how to install it in there with homebrew. Then try the above command again to double check it installed properly.

3. JAVA_HOME path might not be set up properly

Do this in the terminal:

echo $JAVA_HOME

If you see nothing that means your $JAVA_HOME variable is not exported properly. You can solve this by doing this in the terminal:

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

That's all!

like image 60
mesqueeb Avatar answered Sep 17 '22 16:09

mesqueeb


This problem arises when there is no virtual device set up in the system (No target version or no target device). I am not sure if that is a must. You can add a device using SDK manager.

In SDK manager, Add an android repository (For example - Android 5.0.1 API 21) and all dependencies like SDK Tools etc.

Then try cordova requirements. If you are able to run an instance of emulator then this error will go off..(It worked for me that way!)

Hope this helps..

like image 32
pro_cheats Avatar answered Sep 16 '22 16:09

pro_cheats