Marian Klühspies
Marian Klühspies

Reputation: 17637

"provided" scope not working - android studio with gradle

I need to prevent gradle from exporting a certain shared library.

I´ve read that using the provided scope should do the trick, but it seems that it was only working with older gradle versions.

Is there any other way to exclude dependencies from the build process to not get them into the final apk?

Upvotes: 4

Views: 5134

Answers (4)

Dustin
Dustin

Reputation: 2154

Fought with this for a while and found:

  1. "provided" is part of gradle 1.3.0, but doesn't work properly.
  2. "provided" works properly in gradle 1.5.0!

FYI: I had to delete my build directory after upgrading to 1.5.0 to remove the lib file from the .aar.

Upvotes: 0

FeelGood
FeelGood

Reputation: 5614

I have found solution here: https://stackoverflow.com/a/10406184/310760

But for Gradle 2.0 it has small changes:

configurations{
  provided
}

sourceSets {
    main {
        compileClasspath += configurations.provided
    }
    test {
        compileClasspath += configurations.provided
    }
}

sourceSets.main.compileClasspath += configurations.provided

idea {
  module{
    scopes.PROVIDED.plus += [configurations.provided] // for Gradle 2.0
  }
}

Upvotes: 3

Ligboy
Ligboy

Reputation: 126

Solved thie problem by using the android-apt gradle plugin.

see https://bitbucket.org/hvisser/android-apt/overview

apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
    compileSdkVersion 20
    buildToolsVersion '20.0.0'
    defaultConfig {
        applicationId "org.ligboy.test.card.module1"
        minSdkVersion 14
        targetSdkVersion 20
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
configurations {
    apt
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    apt 'com.android.support:support-v4:21.+'
    apt 'com.google.code.gson:gson:2.2.+'
    apt 'com.android.support:cardview-v7:+'
    apt 'com.android.support:recyclerview-v7:+'
}

Upvotes: 0

Ligboy
Ligboy

Reputation: 126

I have the same problem, and I found some solutions.But I don't understand.

http://www.sinking.in/blog/provided-scope-in-gradle/

Upvotes: 0

Related Questions