Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 #11591

Closed
ghost opened this issue May 10, 2017 · 25 comments

Comments

@ghost
Copy link

ghost commented May 10, 2017

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
@biesbjerg
Copy link

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"

@mburger81
Copy link
Contributor

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

@ghost
Copy link
Author

ghost commented May 10, 2017

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

@mburger81
Copy link
Contributor

google how to install gradle on Mac! 😄

@ghost
Copy link
Author

ghost commented May 10, 2017

@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?

@ghost
Copy link
Author

ghost commented May 10, 2017

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

@ghost ghost closed this as completed May 10, 2017
@Mohsen7s
Copy link
Contributor

What to do on windows ?!

@ush189
Copy link

ush189 commented Jun 5, 2017

Here are the steps for windows:
http://bryanlor.com/blog/gradle-tutorial-how-install-gradle-windows

@farskid
Copy link

farskid commented Jul 5, 2017

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/

@chmod-777
Copy link

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 

@gautamc1106
Copy link

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

@Chuckv01
Copy link

Chuckv01 commented Dec 2, 2017

Run this command to install gradle on a mac:

brew update && brew install gradle

@MoemenMostafa
Copy link

MoemenMostafa commented Dec 13, 2017

Upgrading gradle worked for me to 4.4

@sergii-frost
Copy link

sergii-frost commented Feb 1, 2018

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

@hugodes
Copy link

hugodes commented Feb 21, 2018

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

@geraldapeoples
Copy link

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

@strictd
Copy link

strictd commented Feb 24, 2018

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.

@ghost
Copy link

ghost commented Mar 5, 2018

Same issue here.

Run: brew install gradle

@toniyecla
Copy link

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

@bitjson
Copy link

bitjson commented Apr 5, 2018

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/

@kingrnflutter
Copy link

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

@westphalen
Copy link

westphalen commented May 8, 2018

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)

@trinitiwowka
Copy link

trinitiwowka commented May 18, 2018

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

@pabloroxo
Copy link

pabloroxo commented Jun 1, 2018

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)

@ionitron-bot
Copy link

ionitron-bot bot commented Sep 1, 2018

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.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 1, 2018
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests