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

Is it possible to declare a variable in Gradle usable in Java ? Basically I would like to declare some vars in the build.gradle and then getting it (obviously) at build time. Just like a pre-processor macros in C/C++… An example of declaration would be something like that … : android { debug { A_VAR_RETRIEVABLE_IN_JAVA … Read more

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

I have a multi-project (~10 modules) of which building takes about 20-30 seconds each time. When I press Run in Android Studio, I have to wait every time to rebuild the app, which is extremely slow. Is it possible to automate building process in Android Studio? Or do you have any advice on how to … Read more

How to manually include external aar package using Gradle for Android

I’ve been experimenting with the new android build system and I’ve run into a small issue. I’ve compiled my own aar package of ActionBarSherlock which I’ve called ‘actionbarsherlock.aar’. What I’m trying to do is actually use this aar to build my final APK. If I include the whole ActionBarSherlock library as an android-library module to … Read more

Gradle DSL method not found: ‘runProguard’

I get an error after updating from my last project. Not a problem in my code but I’m having trouble with build.gradle. How can I fix it? build.gradle code here: apply plugin: ‘android’ android { compileSdkVersion 21 buildToolsVersion ‘20.0.0’ 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’ … Read more

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

When I build my app, I get the following error: Error: Execution failed for task ‘:app:transformResourcesWithMergeJavaResForDebug’. More than one file was found with OS independent path ‘META-INF/LICENSE’ This is my build.gradle file: apply plugin: ‘com.android.application’ apply plugin: ‘kotlin-android’ android { compileSdkVersion 25 buildToolsVersion “25.0.2” defaultConfig { applicationId “cn.sz.cyrus.kotlintest” minSdkVersion 14 targetSdkVersion 25 versionCode 1 versionName … Read more

Can the Android layout folder contain subfolders?

Right now, I’m storing every XML layout file inside the ‘res/layout’ folder, so it is feasible and simple to manage small projects, but when there is a case of large and heavy projects, then there should be a hierarchy and sub-folders needed inside the layout folder. for e.g. layout — layout_personal — personal_detail.xml — personal_other.xml … Read more

How to add local .jar file dependency to build.gradle file?

So I have tried to add my local .jar file dependency to my build.gradle file: apply plugin: ‘java’ sourceSets { main { java { srcDir ‘src/model’ } } } dependencies { runtime files(‘libs/mnist-tools.jar’, ‘libs/gson-2.2.4.jar’) runtime fileTree(dir: ‘libs’, include: ‘*.jar’) } And you can see that I added the .jar files into the referencedLibraries folder here: … Read more

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

After updating to android studio 2.3 I got this error message. I know it’s just a hint as the app run normally but it’s really strange. All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 25.1.1, 24.0.0. Examples include com.android.support:animated-vector-drawable:25.1.1 and com.android.support:mediarouter-v7:24.0.0 my gradle: dependencies … Read more

Android Studio: Add jar as library?

I’m trying to use the new Android Studio but I can’t seem to get it working correctly. I’m using the Gson library to serialize/deserialize JSON-objects. But the library somehow isn’t included in the build. I had created a new project with just a MainActivity. Copied gson-2.2.3.jar in the /libs folder and added it as a … Read more

What’s the difference between implementation, api and compile in Gradle?

After updating to Android Studio 3.0 and creating a new project, I noticed that in build.gradle there is a new way to add new dependencies instead of compile there is implementation and instead of testCompile there is testImplementation. Example: implementation ‘com.android.support:appcompat-v7:25.0.0’ testImplementation ‘junit:junit:4.12’ instead of compile ‘com.android.support:appcompat-v7:25.0.0’ testCompile ‘junit:junit:4.12′ What’s the difference between them and … Read more