I create ionic 2 project and add diagnostic cordova plugin like this :
ionic plugin add cordova.plugins.diagnostic
npm install --save #ionic-native/diagnostic
and add android platform like this :
ionic platform add android#latest
but when build with ionic build android console give me this error :
Error: Could not find an installed version of Gradle either in Android Studio,
or on your system to install the gradle wrapper. Please include gradle
in your path, or install Android Studio
and I try to download manualy gradle.3.3-all.zip and change this distributionUrl var in platform/android/cordova/lib/builders/GradleBuilder.js
var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'https\\://services.gradle.org/distributions/gradle-3.3-all.zip'
to:
var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'file:///E:/gradles/gradle-3.3-all.zip';
but not working and console give me last error.
I dont know how to add gradle for android#latest version
Life is too short to spend it on messing with paths, etc.
Since I had Homebrew installed on the iMac, I just ran this command:
brew install gradle
The Ionic3 project started to build successfully.
Try installing gradle and include it into your path. Click the link below to get manual.
https://gradle.org/install
Just install gradle on linux, Even if Android Studio is installed,
sudo apt install gradle
For windows users:
Download gradle binary from the link in the answer Gradle Download
Extract the zip file to 'C:\Gradle' or somewhere else
open Edit Environment variable dialog from start menu > Search
Click 'New' under system variables and add as below
Variable Name GRADLE_HOME Variable Value C:\Gradle\gradle-4.0.1
Then choose PATH variable from system variable list
append the gradle path to variable value like this C:\Gradle\gradle-4.0.1\bin
then press win Key+R type cmd then enter > in command terminal type gradle -v
if the setup is correct you will see the gradle installation details
I was already installed Android Studio and it's just need to add gradle PATH to ~/.bash_profile on my MacOSX Mojave.
Also if gradle is upgraded then path might need to update again.
Example .bash_profile :
export ANDROID_SDK_ROOT="~/Library/Android/sdk"
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
export JAVA_HOME=$(/usr/libexec/java_home)
export GRADLE_PATH="~/.gradle/wrapper/dists/gradle-4.10.1-all/455itskqi2qtf0v2sja68alqd/gradle-4.10.1/bin"
export ANDROID_STUDIO="/Applications/Android Studio.app/Contents/MacOS"
export PATH="$PATH:$GRADLE_PATH:$ANDROID_STUDIO"
When edited your .bash_profile then run a command below to read it again.
source ~/.bash_profile
For Windows you can try below solution
Copy your gradle-->bin path and add it to system environment variable path.
In my case gradle path is
C:\Users\username\.gradle\wrapper\dists\gradle-3.3-all\55gk2rcmfc6p2dg9u9ohc3hw9\gradle-3.3\bin
This solution worked for me.
In Ubuntu, Installing latest version of gradle solved the issue for me.
Try these steps to install the latest version,
sudo add-apt-repository ppa:cwchien/gradle
sudo apt-get update
sudo apt-get install gradle
then build using,
cordova build android or ionic cordova build android
Note: If you install gradle from ubuntu repo, it will install the old version 1.4 and will not help, so sudo apt-get install gradle alone will not help most times, if you did not add the repo ppa:cwchien/gradle earlier
There is a problem with cordova version 6.4.0 and android 6.2.1 .so,please try with below compatible versions
cordova version must be 6.4.0
sudo npm install -g cordova#6.4.0
Install android in your project
sudo cordova platform add android#6.1.2
or
sudo ionic platform add android#6.1.2
brew install gradle
In short that will save time :) Ionic team please fix this
On Ubuntu 18.04, I intalled gradle with:
sudo add-apt-repository ppa:cwchien/gradle
sudo apt-get update
sudo apt-get install gradle
And Ready.
If you dont want to install gradle explicitly just to address this issue, you can overcome this by following the workaround as mentioned below:
Look for check_reqs.js file under platforms\android\cordova\lib folder
Edit the else part of androidStudioPath variable null check in get_gradle_wrapper function as below:
Existing code:
else {
//OK, let's try to check for Gradle!
return forgivingWhichSync('gradle');
}
Modified code:
else {
//OK, let's try to check for Gradle!
var sdkDir = process.env['ANDROID_HOME'];
return path.join(sdkDir, 'tools', 'templates', 'gradle', 'wrapper', 'gradlew');
}
NOTE: This change needs to be done everytime when the android platform is removed and re-added
UPDATE: The above workaround will work fine till Cordova Android version 6.3.0. For Cordova Android 6.4.0 and above, Gradle needs to be installed as a standalone dependency. Please find Cordova Android 6.4.0 release notes for more info on this.
For Windows users:
Set-ExecutionPolicy RemoteSigned -scope CurrentUser
iex (new-object net.webclient).downloadstring('https://get.scoop.sh')
scoop install gradle
Just install the Gradle through the command line
If you are using Mac try
brew install gradle
I am on Microsoft Windows:
I encountered this error after upgrading Android Studio from 2.3.3 to 3.0. I solved it by changing the path to gradle in the PATH environment variable, which is now "gradle-4.1" for Android Studio 3.0 (previously it was "gradle-3.2" for Android Studio 2.3.3)
I moved Android folder path to another path and taked this error.
I resolved to this problem in below.
I was changed to Gradle path in system variables. But not path in user variables. You must change to path in system variables
Screenshot this
Alternative Screenshot this
I would like to add my two cents to this conversation. If you are a Windows user, you would like to take advantage of Chocolatey
Per https://community.chocolatey.org/packages/gradle, you need to run
in your console (it assumes you already have Chocolatey installed).
choco install gradle
If you haven't installed Chocolatey, follow the instructions at https://chocolatey.org/install
I solve this problem
Download gradle.zip from this site https://gradle.org/install. And follow the instructions indicated in the site.
Then open another terminal cmd and execute the command:
Cordova build android --prod --release
End
First of all uninstall ionic and cordova, later set your variables envarionment JAVA_HOME, ANDROID_HOME and PATH then reinstall ionic cordova and add platform like follow:
$ sudo npm install -g ionic cordova
$ ionic platform add android
The ionic will setup gradle packages properly.
In Arch Linux/Manjaro:
sudo pacman -S gradle
just install android studio and select your sdk folder as a android studio's sdk default folder and then android studio repair all the damage area and download needed files.
Download the latest gradle from https://gradle.org/install and set the gradle path upto bin in your PATH variable and export path in the directory you are working in
example : export PATH=/home/abc/android-sdk-linux/tools:/home/abc/android-sdk-linux/platform-tools:/home/abc/android-sdk-linux/tools:/home/abc/android-sdk-linux/platform-tools:/home/abc/Downloads/gradle-4.4.1/bin
I spent my whole day resolve this and ultimately this solution worked for me,
If your gradle was working normally before and this came up (probably after you upgraded or reinstalled ionic or cordova - as was my case), you might want to leave the environment variable as is, and check if the folder listed there actually exists.
If it doesn't, rather than reinstalling gradle as mentioned above and changing the value of the environment variable, I had to recreate the old missing folder and copy the gradle files into them.
It seems the value of the gradle location is saved somewhere in Android Studio, and updating the PATH in system variables doesn't affect Android Studio checking for that same location after something triggers a change.
I am going through salesforce trailhead "Get Started with Hybrid Development".
Now, I try to create a forcedroid hybrid android app with command "forcedroid create".
E:\TempTry>forcedroid create
Enter your application type (native, hybrid_remote, or hybrid_local): hybrid_local
Enter your application name: MyTrailHybridLocal
Enter the target directory of your app: TrailHybridApps
Enter the package name for your app (com.mycompany.my_app): com.mytrail.hybrid
But I failed and got an error message as below.
". Should be in the format x[.y[.ignored]]
) is less than the minimum required version (5.4.0). Please update your version
of Cordova.
In fact, folder TrailHybridApps exists and it is empty. And my Cordova is v6.3.0.
E:\TempTry>cordova -v
6.3.0
So, what's wrong? And what can I do now?
Thanks in advance.
In fact, I have succeeded in finishing a Cordova android app acoording to the guide: https://cordova.apache.org/docs/en/latest/guide/cli/
So, I think my Cordova has no problem and it seems that the question resulted from the "npm forcedroid". On the other hand, I have not github installed. Does it have anything to do with github?
Before running forcedroid create, run this command:
cordova telemetry off
Then forcedroid create should work. Or, you could uninstall Cordova and reinstall with a specific version, i.e.:
npm uninstall -g cordova
npm install -g cordova#5.4.0
You don't have to do anything with github.
You need to update your cordova. This guide shows how to modify Android projects to upgrade from older versions of Cordova. Most of these instructions apply to projects created with an older set of command-line tools that precede the cordova CLI utility. See The Command-Line Interface for information on how to update the version of the CLI.
https://cordova.apache.org/docs/en/latest/guide/platforms/android/upgrade.html
Thanks to you all.
At last I worked out this problem. I would like to share with you all here.
I think it must be a bug of Cordova V6.3.0 or forcedroid create.
Refer to : https://github.com/forcedotcom/SalesforceMobileSDK-Android/issues/1209
As for me, Cordova V6.2.0 works fine while V5.4.0 seemed to result in another error message: Error:'com.android.build.gradle.BasePlugin'.
npm uninstall -g cordova
npm install -g cordova#6.2.0
'cordova telemetry off' doesn't work for me.
Thanks again, special to Richard W, miken32, Ali Nfr and Rajasekar.
I have just started with phonegap using below link.
http://docs.phonegap.com/getting-started/1-install-phonegap/desktop/
I have followed all steps and able to run my first phonegap app successfully.
I was really excited till now, but now I am stuck when i want to add plug-in(Speech Synthesis) to same app. doing some google, i found that, i need to install below things. Is there any other easy way for this?
Install Java (Set the path in environmental variables)
Download ADT Bundle and extract it and set the path in environmental variables.
Download and install Node.js from http://nodejs.org/ link. (Set the path in environmental variables if not set automatically)
Download Apache ANT.
Also step by step links for above steps are broken, please suggest the correct and easiest way to add plug-in to phonegap application.
I found it myself now..
below are the steps..
Install npm from https://nodejs.org/en/
Install phonegap CLI with below command
$ npm install -g phonegap
Instal GIT if not installed on your desktop fro their site or using below command.
npm install -g git
Add plugin using below command at the project directory
phonegap plugin add https://github.com/macdonst/SpeechRecognitionPlugin
phonegap plugin add https://github.com/apache/cordova-plugin-battery-status
Open your project again in Phonegap desktop app or use phonegap serve command to test it directly on mobile app.
No need of eclipse, ant, java....
I have a problem during my cordova/phonegap installation. I did every step in this PhoneGap Tutorial
But when I try to execute "$cordova create" I get the message "cordova: command not found". When I try to execute "$phonegap" nothing happens.
Any idea, what to do?
How can I reinstall everything? How can I check my installation?
What version of Cordova do you have installed? The latest stable at this time is 5.4.1
You can check cordova version using the command
cordova --version
If by any chance you ended up with this error after an update, you can try uninstalling Cordova globally using -g(global) flag and install again using sudo npm update -g cordova
For steps regarding installation and update, please refer to the original documentation here
You might need to create a fresh cordova project after installation/update and move your config preferences and www to the freshly created project/folder.
I have an issue with setting up an Android Project on Mac OS.
with the command:
$cordova platform add /path/to/androidSDK/android
I've got the error message:
[Error: Platform "/path/to/androidSDK/android" not recognized as core cordova platform.]
Does anyone have the same Issue ? How can I fix that ?
latest Android SDK version (downloaded today).
Phonegap version: 3.1.0-0.15.0
OSX 10.9 Mavericks
To install the cordova command-line tool, follow these steps:
First of all go through the Cordova Document
For Cordova command-line tools to work, you need to include the SDK's tools and platform-tools directories in your PATH environment. On Mac, you can use a text editor to create or modify the ~/.bash_profile file, adding a line such as the following, depending on where the SDK installs:
export PATH=${PATH}:/Development/adt-bundle/sdk/platform-tools:/Development/adt-bundle/sdk/tools
Next Steps:
Download and install Node.js from Here. Following installation, you should be able to invoke node or npm on your command line.
Install the cordova utility. In Unix(Mac), prefixing the additional sudo command may be necessary to install development utilities in otherwise restricted directories:
For Mac $ sudo npm install -g cordova
once successful installation of cordova is done ,now you can create your application
across all the platforms.
Create the Cordova Application
Go to the directory where you maintain your source code, and run a command such as the following:
$cordova create hello com.example.hello CordovaDemo
hello is the directory where you want to create your application
com.example.hello is the package name
CordovaDemo is the name of the Application
Once Successful creation of your project, some file will be created inside the directory i.e hello
Add Platforms
All subsequent commands need to be run within the project's directory, or any subdirectories within its scope:
$ cd hello
Now you need to specify a set of target platforms, Supported OS for Mac
$ cordova platform add android
plz tell me if you are still having problem.
Hope this will help you.
this is documentation Phonegab docs
and my .bash_profile:
export PATH=${PATH}:$HOME/Development/adt-bundle-mac-x86_64-20140321/sdk/platform-tools:$HOME/Development/adt-bundle-mac-x86_64-20140321/sdk/tools
visit the solution here
I hope this helps you