Reputation: 489
I am trying to build an apk for android by using ionic framework but couldn't building an apk. I have already installed Android studio 3.1.3 and added platform in ionic project also.
ionic cordova add platform android
ionic cordova build android --release
Ionic info:
cli packages: (/usr/local/lib/node_modules)
@ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
global packages:
cordova (Cordova CLI) : 8.0.0
local packages:
@ionic/app-scripts : 3.1.9
Cordova Platforms : android 7.0.0
Ionic Framework : ionic-angular 3.9.2
System:
Android SDK Tools : 26.1.1
Node : v8.11.1
npm : 5.6.0
OS : macOS High Sierra
Xcode : Xcode 7.2.1 Build version 7C1002
Environment Variables:
ANDROID_HOME : /Users/prakash/Documents/adt-bundle-mac-x86_64-20140321/sdk
Misc:
backend : pro
Error message:
ANDROID_HOME=/Users/prakash/Documents/adt-bundle-mac-x86_64-20140321/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home
studio
(node:1272) UnhandledPromiseRejectionWarning: 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
at Object.module.exports.check_gradle (/Users/prakash/IONIC/NABH/platforms/android/cordova/lib/check_reqs.js:150:18)
at StudioBuilder.prepEnv (/Users/prakash/IONIC/NABH/platforms/android/cordova/lib/builders/StudioBuilder.js:216:23)
at Api.module.exports.run (/Users/prakash/IONIC/NABH/platforms/android/cordova/lib/build.js:154:20)
at /Users/prakash/IONIC/NABH/platforms/android/cordova/Api.js:342:43
at _fulfilled (/Users/prakash/IONIC/NABH/platforms/android/cordova/node_modules/q/q.js:854:54)
at self.promiseDispatch.done (/Users/prakash/IONIC/NABH/platforms/android/cordova/node_modules/q/q.js:883:30)
at Promise.promise.promiseDispatch (/Users/prakash/IONIC/NABH/platforms/android/cordova/node_modules/q/q.js:816:13)
at /Users/prakash/IONIC/NABH/platforms/android/cordova/node_modules/q/q.js:624:44
at runSingle (/Users/prakash/IONIC/NABH/platforms/android/cordova/node_modules/q/q.js:137:13)
at flush (/Users/prakash/IONIC/NABH/platforms/android/cordova/node_modules/q/q.js:125:13)
(node:1272) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:1272) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Finally Installed gradle-4.1 file and unzipped it in below path,
/Users/prakash/gradle-4.1
But still getting the above message. Please help me to out from this stuck. Thanks in adv.
Upvotes: 4
Views: 14577
Reputation: 1
I'm using Linux Fedora 30 and my solution was this.
First installing Gradle from the official page
Once downloaded I unzip the file inside my sdk/tools path in my case is this /home/JCODE07/Android/sdk/tools/gradle
The last step Open the .bashrc and added the path of Gradle to my PATH VARIABLE.
export PATH=$PATH:"/home/JCODE07/Android/sdk/platform-tools":"/home/JCODE07/Android/sdk/tools":"/home/JCODE07/Android/sdk/tools/gradle/bin"
I hope this works for you :)
Upvotes: 0
Reputation: 453
How to install gradle in mac
- Open terminal in Mac
- Check whether brew is installed or not, just write brew if it is installed then write
brew install gradle
- If ,it is not installed, install it and write this below line in terminal
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- Now gradle will be install
- Now may be it will give an error
/Users/Desktop/project-name/platforms/android/gradlew: Command failed with exit code EACCES
- Next step will be
sudo chmod 777 /Applications/Android\ Studio.app/Contents/gradle/gradle-4.10.1/bin/
sudo chmod 777 /Users/xyz/Desktop/project-name/platforms/android/gradlew
Happy Setting!! Hola!! This will work.
Upvotes: 0
Reputation: 3062
For Linux: Include the downloaded gradle path
Get your android sdk path... find it in .bashrc at the bottom: ANDROID_HOME=$HOME/Android/Sdk
$ mkdir $HOME/Android/Sdk/gradle
Unzip the gradle folder(that was downloaded earlier) here.
if Gradle was downloaded by SDKMAN, it will save it in $HOME/.sdkman/archives
$ unzip $HOME/.sdkman/archives/*.zip -d $HOME/Android/Sdk/gradle
set the path in .bashrc: for me the Sdk path is:
$ANDROID_HOME == $HOME/Android/Sdk
So you need to do...
export PATH=${PATH}:$ANDROID_HOME/gradle/gradle-5.1.1/bin
$ source1
$ cordova build
Upvotes: 0
Reputation: 145
What worked for me was setting the bin folder inside the gradle folder into the PATH environment variable. So apart from all the steps listed above by @pb123 , additionally I had to set the PATH environment variable to include the gradle bin path. Using the example from his post:
export PATH=${PATH}:$ANDROID_HOME/tools/gradle/bin
You can set it in your ~/.bash_profile, so it becomes available across sessions.
Upvotes: 5
Reputation: 489
finally i got the solution of my own question.
If you have already installed Android Studio and set the Environment variable like,
ANDROID_HOME : /Users/prakash/Documents/adt-bundle-mac-x86_64-20140321/sdk
Then you need to download the gradle and include it into your path. Click the link below to get manual. https://gradle.org/install
Once download completed, follow the below steps:
Step-1: Goto your sdk path. here is my path /Users/prakash/Documents/adt-bundle-mac-x86_64-20140321/sdk/tools
Step-2: create a new folder named as "gradle" and open it.
Step-3: Unzip the gradle folder here which was downloaded earlier.
Step-4: Now open terminal and run your ionic project.
Upvotes: 8