Apache Cordova is a platform to build mobile applications using JavaScript, HTML5 and CSS.
When I was trying to install cordova for creating an android application on my Ubuntu 16.04 I was facing lot of versioning and dependency problems. So in this post I will be discussing about all those issues and the solution that worked for me. All the steps are via command line and so no android studio. I don't want to install GB's of files to just use sdk.
Steps:
Installing latest version of nodejs
By default ubuntu 16.04 has a stable version of nodejs added in its own repository. So to install latest version from Ubuntu itself you can simply use apt commad as follows.
I found a solution for this by using NVM (Node Version Manager). Using nvm you can install as many version of nodejs you want and switch it from version to version conveniently.
Installing nvm on ubuntu 16.04
Close and open the terminal to use nvm (to refresh env) and check the nvm version using following command
Done, Now you have installed Nodejs!
Installing Cordova
To install cordova you can simply use the npm command and rest all will be taken care.
Good! Now you have successfully installed cordova.
Installing android SDK
Downloading sdkmanager:
Goto https://developer.android.com/studio/index.html and scroll down to see "Get Just command line tools" portion and select the sdk download link for linux. Once downloaded extract it to your home directory.
Installing Java if not installed before
Install gradle and adb
Your installed version of java might be different and so make sure you are setting the correct path for JAVA_HOME.
Even after giving correct path for JAVA_HOME I had an issue saying Java path is missing. Basically your java and javac command should point to the same version. You can use following command to choose the required default javac.
When I was trying to install cordova for creating an android application on my Ubuntu 16.04 I was facing lot of versioning and dependency problems. So in this post I will be discussing about all those issues and the solution that worked for me. All the steps are via command line and so no android studio. I don't want to install GB's of files to just use sdk.
Steps:
- Install latest version of node and npm
- Install Cordova
- Install android SDK (Command line)
- Setting environment variables
- Creating android plaform
- Creating and running first app
By default ubuntu 16.04 has a stable version of nodejs added in its own repository. So to install latest version from Ubuntu itself you can simply use apt commad as follows.
$ sudo apt update $ sudo apt install nodejsBut when I was using this version (4.2.6 is the latest stable version available when I was trying) I got some dependency error while trying to install Cordova. So I forced to add 3rd party ppa to get the latest version of nodejs. But the problem is I had some other project which uses this version of nodejs which is really mandatory.
I found a solution for this by using NVM (Node Version Manager). Using nvm you can install as many version of nodejs you want and switch it from version to version conveniently.
Installing nvm on ubuntu 16.04
$ sudo apt install build-essential libssl-dev $ sudo apt install curl $ sudo apt install git $ curl https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bashNote: In the above url v0.31.0 is the nvm version and this is the latest version available when I was installing.
Close and open the terminal to use nvm (to refresh env) and check the nvm version using following command
$ nvm --versionTo install any version of nodejs
$ nvm install 8.1The above command will install latest build available under nodejs version 8.1. To install the latest version of nodejs available in the repository
$ nvm install nodeTo list all the installed nodejs versions
$ nvm lsTo use a version
$ nvm use 4.6Note: 4.6 is the version number
Done, Now you have installed Nodejs!
Installing Cordova
To install cordova you can simply use the npm command and rest all will be taken care.
$ npm install cordovaDon't use sudo when you are using nodejs via nvm, if the installation fails and requires permission. There is a hack to make your current nodejs available for root using following command
n=$(which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/localNote: The above command is copying the current version, so at any time in future you switched to another version and that requires sudo, re-run the above command again.
Good! Now you have successfully installed cordova.
Installing android SDK
Downloading sdkmanager:
Goto https://developer.android.com/studio/index.html and scroll down to see "Get Just command line tools" portion and select the sdk download link for linux. Once downloaded extract it to your home directory.
Installing Java if not installed before
$ sudo apt update $ sudo apt install default-jre $ sudo apt install default-jdkUpdating sdk with required platform-tools
$ cd /home/<user-name>/sdk/tools $ ./android update sdk --no-uiWait for update to finish, you will see "Done!" message once update is completed. Refer this documentation for how to use command line sdk-manager https://developer.android.com/studio/command-line/sdkmanager.html
Install gradle and adb
$ sudo apt install gradle $ sudo apt install adbSetting up cordova environment for Android application
$ cd $ vi .bashrcand add the following environment variables at the end of the file
# Cordova setup export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/; export PATH=$PATH:"/home/<user-name>/sdk/platform-tools/"; export PATH=$PATH:"/home/<user-name>/sdk/tools/"; export PATH=$PATH:"/home/<user-name>/sdk/tools/bin/";Note: <user-name> should be replaced with your Ubuntu user-name. And I am assuming you extracted that sdk zip file to your home directory with name sdk.
Your installed version of java might be different and so make sure you are setting the correct path for JAVA_HOME.
Even after giving correct path for JAVA_HOME I had an issue saying Java path is missing. Basically your java and javac command should point to the same version. You can use following command to choose the required default javac.
$ sudo update-alternatives --config javac
Configuring sdkmanager with dependency:
Install the target android platform
sdkmanager "platforms;android-26"
Creating and testing your first Cordova app
$ cordova create hello com.example.hello HelloWorld $ cd hello $ cordova add platform android
Connect your android device ( I am assuming you have respective driver installed and adb was able to detect your device)
Test your first app
$ cordova run android
If you see the app installed and opened in your mobile. Congrats! you have successfully installed and used Cordova in your Ubuntu.
If you have faced any other issues and found solution for that, please add it in the comments section so that it can help others.
Thanks.
I ABSOLUTELY not suggest this command
ReplyDeleten=$(which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/local
that will ruin all the SU permission.
smm panel
ReplyDeletesmm panel
İs İlanlari
instagram takipçi satın al
hirdavatciburada.com
beyazesyateknikservisi.com.tr
Servis
Tiktok Para Hilesi İndir
Good content. You write beautiful things.
ReplyDeletemrbahis
vbet
hacklink
hacklink
sportsbet
vbet
taksi
mrbahis
korsan taksi
dijital kartvizit
ReplyDeletereferans kimliği nedir
binance referans kodu
referans kimliği nedir
bitcoin nasıl alınır
resimli magnet
V2İ7K