Home » Android » Cordova platform add android error

Cordova platform add android error

Posted by: admin May 14, 2020 Leave a comment

Questions:

Using ubuntu 12.04

cordova platform add android
Creating android project...

/usr/local/lib/node_modules/cordova/node_modules/q/q.js:126
                    throw e;
                          ^
Error: An error occured during creation of android sub-project. 

/home/admin/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:126
                    throw e;
                          ^
Error: An error occurred while listing Android targets
    at /home/admin/.cordova/lib/android/cordova/3.3.0/bin/lib/check_reqs.js:87:29
    at _rejected (/home/admin/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:808:24)
    at /home/admin/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:834:30
    at Promise.when (/home/admin/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:1079:31)
    at Promise.promise.promiseDispatch (/home/admin/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:752:41)
    at /home/admin/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:574:44
    at flush (/home/admin/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:108:17)
    at process._tickCallback (node.js:415:13)

    at /usr/local/lib/node_modules/cordova/src/platform.js:244:30
    at ChildProcess.exithandler (child_process.js:641:7)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:735:16)
    at Socket.<anonymous> (child_process.js:948:11)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Pipe.close (net.js:466:12)

What am I doing wrong?

How to&Answers:

I was having what looks like the same problem. Make sure you add the ADT tools and platform-tools to your system path; doing this fixed the problem for me. Go to your .bashrc file (in your home directory) and add something like:

export PATH=${PATH}:/your-path/android-sdk-linux/platform-tools:/your-path/android-sdk-linux/tools

Then restart your session or do $ source .bashrc to enable the changes. Now cordova should be able to create the Android project just fine.

Answer:

Simple as download sdk, extract somewhere, export that path, do source to take effect, then continue… 🙂

sudo gedit ~/.bashrc

add “PATH=$PATH:/opt/adt-bundle-linux-x86_64-20140321/sdk/platform-tools:/opt/adt-bundle-linux-x86_64-20140321/sdk/tools” to the bottom.

make sure your path specified is correct., adt-bundle-linux-x86_64-20140321 changes according to the version you download.

source ~/.bashrc

to take path in to current session.

then from your build directory (mine is ~/phoneGapBuild/hello ).

cordova platform add android

(@) To see current path variables:

echo $PATH
(If you don’t see newly added variables, please exit terminal and open it again)

(@) If you got an error like

Error: ERROR : executing command ‘ant’, make sure you have ant
installed and added to your path.

run the following comment to install ant.
sudo apt-get -u install ant

Answer:

For windows edit the PATH variable from Control Panel > System > Advanced system settings > Environment Variables. Add the path to Android SDK’s platform-tools and tools folder. For me it was C:\Users\\MyPersonalStuffs\Software\adt-bundle-windows-x86_64-20140321\sdk\platform-tools and C:\Users\\MyPersonalStuffs\Software\adt-bundle-windows-x86_64-20140321\sdk\tools location. Then make sure you open a new terminal tool for the PATH to take effect. Also make sure that you have ant available in the path as well.

Answer:

I had the same problem today on my Windows7. My colleague send me an Ionic project and I couldn’t run it on my device. Finally I removed platforms folder which was created by him and
I add it myself using:

ionic platform add android

and then it run normally after ionic run android

Hope it helps sb.

Answer:

fix is here (FOR WINDOWS ONLY)

I am facing the same problem of Build then i finally found out the solution.

SOLUTION
So You must have the Android Api 23 in order for this command to work.
Error of Daemon process will be solve after installing the Api 23 and extra
build tools and run command
COMMAND : cordova build android –release
I am sure this fix would help you to solve the problem.

STEPS
1. First check the version of android through this COMMAND:
cordova platform help
2. Run the build command after installing the Api 23 and extra build tools.
3. If Even this not work then Try add the variable in the
Environment variables > System variables >
add _JAVA_OPTIONS and value = -Xmx512M

Then Run cordova build android –release

BUT FIRSTLY SET UP THE ENVIRONMENT VARIABLES
Environment Variable setup Image

COPY FROM HERE
ENVIRONMENT VARIABLES:-

  1. USER VARIABLES
    PATH
    C:\Ruby23\bin;C:\Users\kumar\AppData\Roaming\npm;C:\ANDROID_SDK\tools;%SystemRo
    ot%\system32; %SystemRoot%; %SystemRoot%\System32\Wbem;

  2. SYSTEM VARIABLES
    ADD NAME AND VALUE
    2.1 _JAVA_OPTIONS -Xmx512M
    2.2 ANDROID_HOME C:\ANDROID_SDK
    2.3 PATH ->
    C:\ProgramFiles\Java\jdk1.8.0_60\bin;C:\ProgramFiles\nodejs;C:\Gradle\gradle-4.0\bin;C:\ANDROID_SDK\tools;%SystemRoot%\system32; %SystemRoot%; %SystemRoot%\System32\Wbem;%SystemRoot%\system32; %SystemRoot%; %SystemRoot%\System32\Wbem;