build cordova with command line in cygwin - android

I am using cygwin to build the cordova android project.
I created a project successfully
but there is some errors when I build it:
╭─Dozer#Dozer-PC ~/Projects/ba-crm/crm-plus ‹master*›
╰─$ cordova build 127 ↵
Running command: cmd args=["/c","C:\\cygwin64\\home\\Dozer\\Projects\\ba-crm\\crm-plus\\platforms\\android\\cordova\\build"]
ANT_HOME is set incorrectly or ant could not be located. Please set ANT_HOME.
But I have already install all the libraries in cygwin:
╭─Dozer#Dozer-PC ~/Projects/ba-crm/crm-plus ‹master*›
╰─$ ant -version
Apache Ant(TM) version 1.9.3 compiled on December 23 2013
╭─Dozer#Dozer-PC ~/Projects/ba-crm/crm-plus ‹master*›
╰─$ java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
╭─Dozer#Dozer-PC ~/Projects/ba-crm/crm-plus ‹master*›
╰─$ cordova -version
3.4.0-0.1.3

Just because the library is installed does not necessarily mean that the environment variable is set. To see if it's set, in Cygwin I believe you can do echo "$ANT_HOME".
Additionally as the error says, make sure it's set correctly. For example, on my machine ANT_HOME points to C:\Source\ANT\apache-ant-1.8.4.
Lastly, make sure your path is set up to have %ANT_HOME%\bin

export ANT_HOME=c:/path/apache-ant-1.9.4
(export ANT_HOME/cygdrive/c/path/apache-ant-1.9.4 fails - you need the :/ style)

Related

JDK version error when building android app cordova

Im trying to convert angular appliacation to an apk using cordova. When running
cordova build android
I get the following error
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=/home/mohit/Android/Sdk (recommended setting)
ANDROID_HOME=/home/mohit/Android/Sdk (DEPRECATED)
Requirements check failed for JDK 8 ('1.8.*')! Detected version: 11.0.7
Check your ANDROID_SDK_ROOT / JAVA_HOME / PATH environment variables.
Running command:
java --version
openjdk 11.0.7 2020-04-14
OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-2ubuntu218.04)
OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-2ubuntu218.04, mixed mode, sharing)
sudo update-alternatives --set java /usr/lib/jvm/jdk1.8.0_version/bin/java
update-alternatives: error: alternative /usr/lib/jvm/jdk1.8.0_version/bin/java for java not registered; not setting
It's because you use OpenJDK where cordova requires Oracle JavaJDK. Version numbers do not match. Install Oracle JDK.
https://docs.oracle.com/javase/8/docs/technotes/guides/install/mac_jdk.html

configuration jdk in android studio with ubuntu 17.10 not found java home

When I open Android studio, I am getting the following error:
java_home not found
My configuration :
Android Studio 3.0
Ubuntu 17.10 Gnome
java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)
I ran: sudo apt-get install oracle-java8-set-default
(and installed to /usr/lib/jvm/jdk1.8.0/)
I edited "/etc/environment" and set JAVA_HOME="/usr/lib/jvm/jdk1.8.0/"
And added the following lines to "/home/faiberts/.bashrc" and "/root/.bashrc":
export JAVA_HOME="/usr/lib/jvm/jdk1.8.0/"
export PATH=$JAVA_HOME/bin:$PATH"
Do I have some error in some step or it is necessary to change some configuration because I am confused since this is my first time trying to do development in android.
Thank you in advance for your valuable help.

ionic build android : Error :Failed to run “java -version ”

windows 10
ionic 1.7.15
please help me
ionic build android
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b15)
Java HotSpot(TM) Client VM (build 25.91-b15, mixed mode, sharing)
Error: Failed to run "java -version", make sure that you have a JDK installed.
You can get it from: http://www.oracle.com/technetwork/java/javase/downloads.
Your JAVA_HOME is invalid: C:\Program Files (x86)\Java\jre1.8.0_91
JAVA_HOME environment variable should be set to java jdk installation path folder not jre installation path. As per your error trace, your java home is set to jre path which could be the issue

cordova platform add android JAVA_HOME error in Ubuntu

I'm trying to start android development with Cordova on Ubuntu.
I can't add android platform for my project:
$ sudo cordova platform add android
Checking Android requirements...
[Error: ERROR : Make sure JAVA_HOME is set, as well as paths to your JDK and JRE for java.]
Environment checks:
$ java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
$ ant -version
Apache Ant(TM) version 1.8.2 compiled on May 18 2012
echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/programs/adt-bundle/sdk/platform-tools:/programs/adt-bundle/sdk/tools
$ echo $JAVA_HOME
/usr/lib/jvm/jdk1.7.0_45
Eclipse ADT-Boundle is in /programs/adt-boundle folder
Please, tell me, why am I still getting this error?
[Error: ERROR : Make sure JAVA_HOME is set, as well as paths to your JDK and JRE for java.]
This got rid of the JAVA_HOME error for me:
~/.bashrc file:
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386
I also had to add:
export PATH=~/path/where/I/put/bundle/adt-bundle-linux-x86-20131030/sdk/tools
export PATH=~/path/where/I/put/bundle/adt-bundle-linux-x86-20131030/sdk/platform-tools
to get past another error
The error is simlar in Mac
I'm same bug
Checking Android requirements...
[Error: ERROR : Make sure JAVA_HOME is set, as well as paths to your JDK and JRE for java.]
https://issues.apache.org/jira/browse/CB-5422
After few days I tried cordova platform add android again and it worked good. Wery strange. I changed nothing.

How to build android project with openjdk on Ubuntu?

I found this Is Sun Java really necessary for using Android SDK on Ubuntu 10.10? I prefer OpenJDK but I can't build android project on Ubuntu. When I try:
$ ant debug
I got:
Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-6-openjdk/lib/tools.jar
...
BUILD FAILED
/home/kuba/projects/Android/android-sdk-linux/tools/ant/build.xml:651: The following error occurred while executing this line:
/home/kuba/projects/Android/android-sdk-linux/tools/ant/build.xml:672: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "/usr/lib/jvm/java-6-openjdk/jre"
I have java version:
$ java -version
java version "1.6.0_20"
OpenJDK Runtime Environment (IcedTea6 1.9.13) (6b20-1.9.13-0ubuntu1~10.10.1)
OpenJDK Client VM (build 19.0-b09, mixed mode, sharing)
Make sure you have the openjdk JDK installed. By default you probably only have the JRE installed. If you open Synaptic, search for openjdk and then you'll see both the JDK and the JRE. Select the JDK package and install. I think the actual packagename is openjdk-6-jdk.
or use the commandline
# sudo apt-get install openjdk-6-jdk
Android's official webpage reccomends the use of the official JDK from Sun/Oracle that you can download at http://www.oracle.com/technetwork/java/javase/downloads/index.html , the use of OpenJDK is unsupported and highly unrecommended.
You don't need to install the official JDK in your system, if this is what you are worring about, just download the *.bin version of the JDK of your choice ( i suggest the 1.6 version ), unpack everything by executing the *.bin in a terminal, and just modify 2 environment variable like this:
PATH , add the path to the jdk executables path_to_jdk/bin/ to your PATH
JAVA_HOME , set JAVA_HOME to the generic path of your jdk, NOT the bin or lib path, just as before without bin, only path_to_jdk/
you can modify this variables by editing the /etc/bash.bashrc or your local .bashrc, I suggest to edit the one under /etc
you also want to remove your actual OpenJDK from your system.
I've fixed same error (in Debian/Ubuntu) by installing gcj-jdk.
Before installing this package i had java-7-openjdk, but no tools.jar inside its directory.
After installing gcj-jdk I've located tools.jar and made a symlink to it inside directory where ant wants it to be.

Categories

Resources