How to define Gradle’s home in IDEA?

You can write a simple gradle script to print your GRADLE_HOME directory. task getHomeDir { doLast { println gradle.gradleHomeDir } } and name it build.gradle. Then run it with: gradle getHomeDir If you installed with homebrew, use brew info gradle to find the base path (i.e. /usr/local/Cellar/gradle/1.10/), and just append libexec. The same task in … Read more

Gradle Implementation vs API configuration

Gradle compile keyword was deprecated in favor of the api and implementation keywords to configure dependencies. Using api is the equivalent of using the deprecated compile, so if you replace all compile with api everything will works as always. To understand the implementation keyword consider the following example. EXAMPLE Suppose you have a library called … Read more

How to update gradle in android studio?

Step 1 (Use default gradle wrapper) File→Settings→Build, Execution, Deployment→Build Tools→Gradle→Use default Gradle wrapper (recommended) Changing to Gradle Wrapper in the new version of Android Studio: Step 2 (Select desired gradle version) File→Project Structure→Project The following table shows compatibility between Android plugin for Gradle and Gradle: Latest stable versions you can use with Android Studio 4.1.2 … Read more

Is it possible to declare a variable in Gradle usable in Java?

Here are two ways to pass value from Gradle to use in Java; Generate Java Constants android { buildTypes { debug { buildConfigField “int”, “FOO”, “42” buildConfigField “String”, “FOO_STRING”, “\”foo\”” buildConfigField “boolean”, “LOG”, “true” } release { buildConfigField “int”, “FOO”, “52” buildConfigField “String”, “FOO_STRING”, “\”bar\”” buildConfigField “boolean”, “LOG”, “false” } } } You can access … Read more

Building and running app via Gradle and Android Studio is slower than via Eclipse

Hardware I’m sorry, but upgrading development station to SSD and tons of ram has probably a bigger influence than points below combined. Tools versions Increasing build performance has major priority for the development teams, so make sure you are using latest Gradle and Android Gradle Plugin. Configuration File Create a file named gradle.properties in whatever … Read more

How to manually include external aar package using Gradle for Android

Please follow below steps to get it working ( I have tested it up to Android Studio 2.2) Lets say you have kept aar file in libs folder. ( assume file name is cards.aar ) then in app build.gradle specify following and click sync project with Gradle files. Open Project level build.gradle and add flatDir{dirs … Read more

How to clear gradle cache?

Gradle cache is located at On Windows: %USERPROFILE%\.gradle\caches On Mac / UNIX: ~/.gradle/caches/ You can browse to these directory and manually delete it or run rm -r $HOME/.gradle/caches/ on UNIX system. Run this command will also force to download dependencies. UPDATE Clear the Android build cache of current project NOTE: Android Studio’s File > Invalidate … Read more