ionic-framework: 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

Ionic version:

[x] 3.x

I’m submitting a …
[x ] bug report

Current behavior:

ionic run android --prod results in below 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

Expected behavior:

ionic run android --prod must build and run on device connected

Ionic info:

Cordova CLI: 7.0.0 
Ionic Framework Version: 3.1.1
Ionic CLI Version: 2.2.3
Ionic App Lib Version: 2.2.1
Ionic App Scripts Version: 1.3.7
ios-deploy version: 1.8.6 
ios-sim version: 5.0.8 
OS: macOS Sierra
Node Version: v6.10.1
Xcode version: Xcode 8.2.1 Build version 8C1002

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 25 (3 by maintainers)

Most upvoted comments

On cordova@7.0.0 and SDK Tools 26.x.x you have to install gradle by your own.

If you have an debian/ubuntu system you can do this like that sudo apt-get install gradle

google how to install gradle on Mac! 😄

Run this command to install gradle on a mac:

brew update && brew install gradle

@mburger81 - how to get this on Mac OS? I don’t have Android Studio Installed

Here is the solution I found for Mac

Download the Gradle Binary Only Distribution from https://gradle.org/gradle-download/

Open a terminal Run the following to unzip the android sdk to the Development directory that is under your user home directory

unzip ~/Downloads/gradle-3.1-bin.zip -d ~/Development Open up the vi editor and edit your bash profile. We need to add in the GRADLE_HOME environment variable

vi ~/.bash_profile To edit in vi hit i to enter edit mode and add the text below to the .bash_profile

export GRADLE_HOME=~/Development/gradle-3.1/bin Press the esc key to exit edit mode Press : (colon key) to enter command mode. type wq and press enter to save and exit vi Run the following to make the change active in your existing session

source ~/.bash_profile Test it by running

echo $GRADLE_HOME

Did you do as suggested by the error message?

You need to install Android Studio make sure it’s in your PATH.

Here’s my PATH for example: PATH="/Users/kim/.node/bin:/usr/local/bin:/usr/local/sbin:~/bin:/Users/kim/Library/Android/sdk/platform-tools:/Users/kim/Library/Android/sdk/tools:/Users/kim/Library/Android/sdk/build-tools/22.0.1:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"

Thanks to @bitjson I could configure the .bash_profile to be:

export JAVA_HOME=$(/usr/libexec/java_home)
export ANDROID_HOME=/Users/$USER/Library/Android/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:/Applications/Android\ Studio.app/Contents/gradle/gradle-4.4/bin

And this command (I was gettind EACCESS error):

sudo chmod a+x "/Applications/Android Studio.app/Contents/gradle/gradle-4.4/bin/gradle"

I could ionic cordova run android my app!

(Mac OS X + Ionic + NodeJS = last versions)

This issue shouldn’t be closed, the issue is still present using the latest Android Studio, cordova and ionic

What to do on windows ?!

On macOS, if you’d prefer to avoid installing an extra copy of Gradle, you can simply use the tooling installed by Android Studio by adding the following to your ~/.bash_profile (or equivalent):

export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home
export ANDROID_HOME=/Users/$USER/Library/Android/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:/Applications/Android\ Studio.app/Contents/gradle/gradle-4.4/bin

Note: in the future, you’ll likely need to change the version above from gradle-4.4. To check the version you have installed, just:

ls /Applications/Android\ Studio.app/Contents/gradle/

For me this happened because I upgrade Cordova to version 7.0 and gradle version had to be upgraded to 4.0. I upgraded with brew update && brew install grade on MacOS. https://gradle.org/install/

gradle@4.4 (install sdkman, sdk install gradle 4.4)working for cordova android@7.1.0

Same issue here.

Run: brew install gradle

This issue is closed currently, but it still does not seem to work without explicit installation of Gradle. In my case I have:

  • latest Android Studio installed (v3.0.1) (under Applications/ folder which is default location)
  • latest android-sdk installed

This setup works smoothly for Android native apps development (via Android Studio) but I am still getting error when trying to build ionic based project when trying to compile it with cordova compile android --debug:

CordovaError: 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

My ionic info output:

cli packages: (...)

    @ionic/cli-utils  : 1.19.1
    ionic (Ionic CLI) : 3.19.1

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    @ionic/app-scripts : 3.1.5
    Cordova Platforms  : android 7.0.0 ios 4.5.4
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 26.1.1
    ios-sim           : 6.1.2
    Node              : v9.4.0
    npm               : 5.6.0
    OS                : macOS High Sierra
    Xcode             : Xcode 9.2 Build version 9C40b

Environment Variables:

    ANDROID_HOME : /Applications/android-sdk

Misc:

    backend : pro

export GRADLE_HOME=“/usr/local/lib/gradle-4.6/bin” export PATH=“$PATH:$ANDROID_HOME:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$GRADLE_HOME”

I am using Linux Mint 18 Cinnamon and was experiencing the same problem. The problem was happening even though I have an ionic 1 setup and Android that is building with no issues.

I resolved it by installing gradle sudo apt-get install gradle Gradle was automatically added to the PATH and the various ionic build commands worked without a hitch.

ionic info:

@ionic/cli-utils  : 1.7.0
ionic (Ionic CLI) : 3.7.0

System:

Android SDK Tools : 25.2.2
Node              : v7.10.0
OS                : Linux 4.4
npm               : 4.2.0