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

More than one file was found with OS independent path ‘META-INF/LICENSE’

You can add this in yourProject/app/build.gradle inside android{}. The exclude function adds the named resource to the list of resources that are not packaged in the APK. android { packagingOptions { exclude ‘META-INF/DEPENDENCIES’ exclude ‘META-INF/LICENSE’ exclude ‘META-INF/LICENSE.txt’ exclude ‘META-INF/license.txt’ exclude ‘META-INF/NOTICE’ exclude ‘META-INF/NOTICE.txt’ exclude ‘META-INF/notice.txt’ exclude ‘META-INF/ASL2.0’ exclude(“META-INF/*.kotlin_module”) } } The exclude function is deprecated … Read more

All com.android.support libraries must use the exact same version specification

You can solve this with one of the following solutions: Update: As of Android studio 3.0, it becomes much easier as it now shows a more helpful hint, so we only need to follow this hint. for example: All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). … Read more