Help me to set up comile dependencies in Android Studio in build.gradle. I mean that they not include into final APK.
this build.gradle works fine but i don't need
lombok
library in apk in runtime;
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 10
targetSdkVersion 16
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
} }
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile 'org.projectlombok:lombok:1.12.2' }
And may be its possible to setup in global build.gradle file for all projects?
In addition to setting up your gradle project correctly, you need to add the Lombok IntelliJ plugin to add lombok support to Android Studio: Go to File > Settings > Plugins. Click on Browse repositories... Search for Lombok Plugin.
With Android Studio 1.1.0, I couldn't find a consolidated set of instructions for adding Lombok that worked for me. That includes Lombok's own setup page: http://projectlombok.org/setup/android.html
Here's everything I had to do to get it working (on OS X):
Browse repositories...
Install plugin
provided 'org.projectlombok:lombok:1.16.2'
subprojects
approach in build.gradle in the project root (from Олександр Самсонов's answer) works also, but it appears that requires moving the configuration from app/build.gradle (you aren't allowed to further extend the configuration in the subprojects). I didn't want to move the entire android configuration, so I kept it in the app/build.gradle instead.lombok.config
file in the root of the project containing two lines:
lombok.anyConstructor.suppressConstructorProperties = true
lombok.addGeneratedAnnotation = false
The ability to do this was just added to the v0.8 Android-Gradle plugin, which you can use if you're running Android Studio 0.4.3 (which is available on the canary update channel).
It's mentioned in the release notes and a thread on the adt-dev mailing list
You specify it like this:
dependencies {
provided 'org.projectlombok:lombok:1.12.2'
}
I've filed bug https://code.google.com/p/android/issues/detail?id=65216 to request the ability to edit this through the Dependencies panel in the Project Structure dialog; for the moment you have to edit your build.gradle file by hand to use this.
As for whether you can put it in the top-level build.gradle file to have it apply to all modules, I'm not certain. I tried putting it in the allprojects
block, but Gradle told me that the default dependency handler didn't know what to do with it. So I'm guessing no, but if I get other information, I'll update this answer.
For Android Studio
I resolve this issue by changing gradle-wrapper.properties
file in gradle folder.
Now it looks like this:
#Sat Jan 25 02:59:06 EET 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip
and in main build.gradle
file i can wrote this for lombok
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
subprojects {
apply plugin: 'android'
buildscript {
repositories {
mavenCentral()
}
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 10
targetSdkVersion 16
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
provided 'org.projectlombok:lombok:1.12.2'
}
}
Now in sub projects i don't need write many params for plugins or repositories and provided method works pretty fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With