Error during executing Android command: Ant Jar - android

So this is the error I get when I try to run any command except "create".
An error occurred during creation of android sub-project. Creating Cordova project for the Android platform: Command failed to execute : ant jar
These are my PATHS
PATH "%JAVA_HOME%\bin;%ANT_HOME%\bin"
JAVA_HOME "C:\Program Files\Java\jdk1.7.0_45"
ANT_HOME "C:\java\ant\apache-ant-1.8.2"
My OS: Windows 8
PS: I've gone through every single post that stated this error but, none of the responses solved my issue.

I discovered this was a phonegap version related issue. When I updated it was all fine.

Related

Cordova - Error code 1 for command | Command failed for

I'm new on cordova, so if my question is not relevant, forgive me.
i have a cordova project in my Windows 7 x64 machine.
Yesterday i was build my cordova app via cordova build android --release.
But i need to add new plugin cordova-plugin-zip to update my cordova project.
What i did to add this plugin to my cordova app;
I installed a git application to my win7 x64 env.
npm install -g git i wrote this command on cmd.
I Opened Windows Environment Variables/Path Window and added ;C:\Program Files (x86)\Git\bin;C:\Program Files (x86)\Git\cmd
add plugin via this command cordova plugin add https://github.com/apache/cordova-plugin-file.git
then added other plugin cordova plugin add https://github.com/MobileChromeApps/zip.git
(Everything fine till this step)
Then i run on cmd cordova build android --release
Unfourtunately it throws following error;
BUILD FAILED C:\android\sdk\tools\ant\build.xml:720: The following
error occurred while execu ting this line:
C:\android\sdk\tools\ant\build.xml:734: Compile failed; see the
compiler error o utput for details.
Total time: 7 seconds
C:\hascevher\platforms\android\cordova\node_modules\q\q.js:126
throw e;
^ Error code 1 for command: cmd with args: /s,/c,ant,release,-f,C:\hascevher\platf
orms\android\build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
ERROR building one of the platforms: Error: cmd: Command failed with
exit code 1
You may not have the required environment or OS to build this project
Error: cmd: Command failed with exit code 1
at ChildProcess.whenDone (C:\Users\Hddn\AppData\Roaming\npm\node_modules\cor
dova\node_modules\cordova-lib\src\cordova\superspawn.js:134:23)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
When i try to create a new helloworld cordova project and adding android platform then from cmd cordova build android it creates sample app?
So what is wrong with my other application?
Any help greatly appricated.
OS: Windows 7 x64
Cordova v 5.1.1
Ant version 1.9.4
Plugins On Cordova Project:
cordova-plugin-file
cordova-plugin-zip
org.apache.cordova.console
org.apache.cordova.device
org.apache.cordova.inappbrowser
Full Windows Environment Variables/Path:
C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Common
Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common
Files\Microsoft Shared\Windows
Live;%C_EM64T_REDIST11%bin\Intel64;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program
Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files
(x86)\Windows Live\Shared;C:\Program Files
(x86)\QuickTime\QTSystem\;C:\Program Files
(x86)\Java\jdk1.7.0_75\bin;C:\cordova\apache-ant-1.9.4\bin;C:\android\sdk\tools;C:\android\sdk\platform-tools;C:\Program
Files\nodejs\;C:\Program Files (x86)\Git\bin;C:\Program Files
(x86)\Git\cmd
I removed android platforms and installed again then worked. I wrote these lines in command window:
cordova platform remove android
then
cordova platform add android
Delete platforms/android folder and try to rebuild. That helped me a lot.
(Visual Studio Tools for Apache Cordova)
Delete all the apk files from platfroms >> android >> build >> generated >> outputs >> apk
and run command cordova run android
I found answer myself; and if someone will face same issue, i hope my solution will work for them as well.
Downgrade NodeJs to 0.10.36
Upgrade Android SDK 22
I have had this problem several times and it can be usually resolved with a clean and rebuild as answered by many before me. But this time this would not fix it.
I use my cordova app to build 2 seperate apps that share majority of the same codebase and it drives off the config.xml. I could not build in end up because i had a space in my id.
com.company AppName
instead of:
com.company.AppName
If anyone is in there config as regular as me. This could be your problem, I also have 3 versions of each app. Live / Demo / Test - These all have different ids.
com.company.AppName.Test
Easy mistake to make, but even easier to overlook. Spent loads of time rebuilding, checking plugins, versioning etc. Where I should have checked my config. First Stop Next Time!
I had the same error code but different issue
Error: /Users/danieloram/desktop/CordovaProject/platforms/android/gradlew: Command failed with exit code 1 Error output:
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0
To resolve this issue I opened the Android SDK Manager, uninstalled the latest Android SDK build-tools that I had (24.0.3) and installed version 23.0.3 of the build-tools.
My cordova app then proceeded to build successfully for android.
In my case it was the file size restriction which was put on proxy server. Zip file of gradle was not able to download due this restriction. I was getting 401 error while downloading gradle zip file. If you are getting 401 or 403 error in log, make sure you are able to download those files manually.
Faced same problem. Problem lies in required version not installed.
Hack is simple Goto Platforms>platforms.json
Edit platforms.json in front of android modify the version to the one which is installed on system.
I'm using Visual Studio 2015, and I've found that the first thing to do is look in the build output.
I found this error reported there:
Reading build config file: \build.json... SyntaxError: Unexpected
token
The solution for that was to remove the bom from the build.json file
Then I hit a second problem - with this message in the build output:
FAILURE: Build failed with an exception. * What went wrong: A
problem was found with the configuration of task ':packageRelease'.
File 'C:\Users\Colin\etc' specified for property
'signingConfig.storeFile' is not a file.
Easily solved by putting the correct filename into the keystore property

Phonegap 3.3 Build Android Failed

I'm trying to build a project but when I type: cordova build android the following error occurred:
Generating config.xml from defaults
for platform "android"
Preparing android project
Compiling app on platform "android"
via command "../platforms/android/cordova/build"
Error: An error occurred
while building the android project.Error executing "ant debug -f "../platforms/android/build.xml"":BUILD FAILED /usr/local/Cellar/android-sdk/22.3/tools/ant/build.xml:932:The following error occurred
while executing this line: /usr/local/Cellar/android-sdk/22.3/tools/ant/build.xml:950:null returned: 1
Total time: 18 seconds
at ChildProcess. < anonymous > (/usr/local/lib/node_modules/cordova/src/compile.js:65:22)
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)
Is there a fix for this problem?
EDIT
I used brew to install Android-SDK and installed all possible build-tools:
And my android manifest looks like:
EDIT2
As requested here is the responce for cordova build android --verbose: http://pastebin.com/rqdkVKYG
I found the bug.
While testing, reinstalling android-sdk and ant. I tried to create a new project. Than typed in the terminal cordova build and it build flawlessly. After this I copied my existing WWW folder in to the new project. Typed cordova build again, it gave an error. Now I knew that the bug was in my WWW folder and not in the project itself. Scanning my folders I noticed a file with no extension(hidden files). I deleted the file and tried again. Success!
SUMMARY:
Scan your folders for files without extensions and delete or move them. Cordova doesn't like those.
EDIT
If this doesn't work try:
cordova platform rm android
then reinstall android using :
cordova platform add android
Now try to build.
try to run the command $home/.cordova/lib/android/cordova/3.3.0/bin/check_reqs to check if you have all the required components installed for android.
¿Did you add to windows path the sdk?
You can also try:
cordova platform add android
cordova build
try ant -v in your terminal and make sure it's above 1.8. Cordova requires that.
Also check path is given correct for Ant, Android-SDK/tools, and Android-SDK/platformtools
To debug exact issue try $Cordova build android --verbose
Let me know.

"phonegap run android" phonegap 3 under windows can't build a project

I 'm trying to create a new project with phonegap3 :-
I set up the dev environment that include
node.js
Ant
Android SDK
and they all updated to the last versions
after creating the project , I get the directory for project:
EX :
phonegap create HelloWorld com.example.hello HelloWorld
but the main problem that I can't add the android platform to it
with the 3 comands as follow :-
trying to "phonegap add platform android"/"phonegap build android"/"phonegap run android"
I also installed throw the node the "cordova" and the same problem exists when I replace the phonegap with cordova !
Users\koko\test\www>phonegap build android
[ponegap] detecting Android SDK environment...
[ponegap] using the local environment
[onegap] adding the Android platform...
[error] An error occured during creation of android sub-project.
Users\koko\.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 C:\Users\koko\.cordova\lib\android\cordova\3.3.0\bin\lib\check_reqs.js:87:29
at _rejected (C:\Users\koko\.cordova\lib\android\cordova
.........
at process._tickCallback (node.js:415:13)
I also uninstall the node and re-download it and the problem still exists !
I viewed many questions with people around this issue but I don't know where exactly the error !
I wish to see the project running inside the emulator !
It seems, that cordova failed to execute following command in shell:
>android list target
Why don't you try to execute it manually? It may produce more information about this problem.
Didn't you forget to add following folders to your PATH?
android-sdk/tools
android-sdk/platform-tools
EDIT:
The latest android SDK has different folder structure. note the "sdk" folder.
android-sdk/sdk/tools
android-sdk/sdk/platform-tools
Make sure, you have set the following system variables:
ANT_HOME = path to ant files
JAVA_HOME = path to java JDK (NOT JRE!!)
ANDROID_HOME = path to android sdk
After that, you have to add
%ANT_HOME%\bin
%JAVA_HOME%\bin
%ANDROID_HOME%\bin
to your PATH variable.
If it still doesnt work, make sure you have the Google USB Driver installed (this took me hours to find and fix -.-)

PhoneGap 3.0 Android build Command failed to execute : ant jar

I installed PhoneGap 3.0 with Node.js and configured all the environment variables so that javac, java, and ant all work but when I do a basic app create and try to build it for Android, I get the following error:
An error occurred during creation of android sub-project. Creating Cordova project for the Android platform: Command failed to execute : ant jar
Any ideas?
Make sure you have the Android Build Tools installed for your Android SDK version. In the Android SDK manager under Tools>Android SDK Build-tools you should see that the Build tools for your SDK version are not installed.
Detail on how I uncovered this:
To identify this as the root cause I ran the Cordova command with -d for verbosity:
cordova -d platform add android
The output of this command shows the error:
Running bin/create for platform "android" with command: ""C:\Users\---\.cordova\lib\android\cordova\3.1.0\bin\create" "C:\Users\---\workspace_android\FleetView\platforms\android" "com.---.fleetview" "Fleet View"" (output to follow)
Running the offending command directly:
"C:\Users\---\.cordova\lib\android\cordova\3.1.0\bin\create" "C:\Users\---\workspace_android\FleetView\platforms\android" "com.---.fleetview" "Fleet View"
produces this output:
BUILD FAILED
C:\tools\adt-bundle-windows-x86_64-20130219\sdk\tools\ant\build.xml:479: SDK does not have any Build Tools installed.
Total time: 1 second
Command failed to execute : ant jar
I am on Windows 7.
This is due to ANT tools could not find tools.jar in JRE lib directory. When I copied tools.jar from JDK lib directory to JRE lib directory, the problem was absolutely solved and the build was successful when I ran the command "cordova -d platform add android". Hope this helps you.
Posted the answer to similar question: Android Platform Guide trouble with adding a platform through the command line
A combination of 2 things worked for me:
include the JDK in your path (path\to\jdk\bin of course)
exclude the JRE from your path (or at least have it come after the JDK)
I faced the same issue,
I was having jdk-6 and I updated to jdk-7,
that fixed the issue,
Also I didn't installed ant in the first place,
in your case ant PATH might be missing.
See if that helps.

Cordova (v3.0.0) CLI failing on Mac - no output for 'which android' command

All,
I am trying to upgrade to Cordova v3.0.0 and have installed the cordova package from npm, have installed the latest Android SDK and ensured the necessary PATH variables are in place.
Also I can run adb and android commands from terminal, but I noticed that I don't get any output for which android command.
And the which not resolving I believe is the error I am getting when I try to do cordova platform add android in my newly created project. The error is:
[Error: An error occured during creation of android sub-project. An unexpected error occurred: ANDROID_BIN="${ANDROID_BIN:=$( which android )}" exited with 1
Deleting project...
]
I have been poring over all the Google search results for this error and as to why which android does not resolve, but to no avail.
Could someone please help me out?
Figured out finally !
I had included the platform-tools and tools like this:
PATH="~/android/sdk/tools:~/android/sdk/platform-tools:$PATH"
And when I changed that to the below, it just started working...
PATH="/Users/<username>/android/sdk/tools:/Users/<username>/android/sdk/platform-tools:$PATH"
So much for the which implementation in Mac. Hope this might helps someone starting with Mac like me.

Categories

Resources