Android Question

How to set up compile library in android studio. LOMBOK

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?

Answer

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.

Comments