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

Created on 10 May 2017  ·  25Comments  ·  Source: ionic-team/ionic-framework

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

Most helpful comment

On [email protected] andSDK 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

All 25 comments

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"

On [email protected] andSDK 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

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

google how to install gradle on Mac! :smile:

@mburger81 - I meant i am using android sdk via local directory, all development was moving smoothly till now, it was only after v3.1.1 upgrade the gradle stopped working; still i need to install Studio?

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

What to do on windows ?!

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/

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

I have the same issue. I have android studio. How do i get it in my path?

Run this command to install gradle on a mac:

brew update && brew install gradle

Upgrading gradle worked for me to 4.4

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

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

This issue should not be closed, I have the latest android studio, ionic and cordova and it will not build even the sample project.

I had this same issue after updating the android ionic platform, my solution was to open Android Studio and SDK Manager to update android 8.0 (Oreo) API Level 26.

Same issue here.

Run: brew install gradle

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

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/

Thank you mburger81.
I can fix the bug in my android project by your help with your blog.
Highly recommend you.
:)

Rather than redundantly installing another copy of Gradle, add your Android Studio gradle to PATH as @bitjson suggested.

However, it didn't work for me at first, you have to be aware of the space in the path.
(Backslash escaping won't work inside quotes)

[email protected] (install sdkman, sdk install gradle 4.4)working for cordova [email protected]

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)

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TheMohanraj picture TheMohanraj  ·  159Comments

mhartington picture mhartington  ·  75Comments

Sturgelose picture Sturgelose  ·  83Comments

wonderdogone picture wonderdogone  ·  121Comments

rvanbaalen picture rvanbaalen  ·  72Comments