Eva Cohen
Eva Cohen

Reputation: 505

ionic 4 - build android - Could not find an installed version of Gradle even though it is installed

I'm developing an app in Ionic 4, ubuntu 18 is my OS. now I want to publish the app on android

when I type: sudo ionic cordova build android --prod --release

I get the following error:

Android Studio project detected ANDROID_HOME=/usr/lib/android-sdk JAVA_HOME=/usr/lib/jvm/java-8-oracle/bin/java"
studio Could not find an installed version of Gradle either in Android Studio,

but I did install gradle:

myApp git:(master) ✗ gradle -v


Gradle 5.2.1

Build time: 2019-02-08 19:00:10 UTC Revision: f02764e074c32ee8851a4e1877dd1fea8ffb7183

Kotlin DSL: 1.1.3 Kotlin: 1.3.20 Groovy: 2.5.4 Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018 JVM: 1.8.0_201 (Oracle Corporation 25.201-b09) OS: Linux 4.15.0-45-generic amd64

also inside my ~/.zshrc file has:

export ZSH="/home/itamar/.oh-my-zsh"
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
export JAVA_HOME="/usr/lib/jvm/java-8-oracle/bin/java"
export PATH=$PATH:/opt/gradle/gradle-5.2/bin

Upvotes: 3

Views: 11145

Answers (2)

Muhammed Albarmavi
Muhammed Albarmavi

Reputation: 24454

On [email protected] and above and SDK Tools 26.x.x you have to install gradle by your own or if gradle installed you have to make sure it is available from command line;

in my case I use windows so I have install gradle manually and extract the zip file in C drive and set the path C:\gradle-6.0\bin

set gradle path

check if gradle working

enter image description here

for Unix-based systems

$ sdk install gradle 6.0.1

for macOS you homebrew package manager

$ brew install gradle

the issue discussed here at github .

Upvotes: 3

Tachyon
Tachyon

Reputation: 2411

Solution #1

The first thing I would try is to run the command without sudo so just run ionic cordova build android --prod --release

If that doesn't work try solution #2


Solution #2

What you want to do is download the gradle bundle from their website. Once you have downloaded the Gradle binaries you want to do the following:

  1. Navigate to your SDK path i.e. cd $HOME/Android/Sdk/tools
  2. Create a new folder called gradle
  3. Navigate into the directory cd ./gradle
  4. Extract the binaries you downloaded earlier to the folder
  5. Run the command again ionic cordova build android --prod --release

Upvotes: 2

Related Questions