0

I'm currently trying to add a library relying on froger_mcs' answer in this post.

Unfortunately, I didn't manage to find build.gradle in library's source files to complete last step:

At the end you have to create another build.gradle file in /libriaries/actionbarsherlock/ directory.

So I added one found in gipi's answer here.

I ended up facing the following problem:

When I run ./gradlew clean it says that gradle version 1.9 is required for the library I'm trying to add. When I change version in gradle-wrapper.properties to 1.9 and run the same task again, it says that gradle version 1.8 is required for my application.

What am I missing?

MyProject/external/TheLibrary/build.gradle:

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:0.7.+'
    }
}

apply plugin: 'android-library'

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
       }
    }
}

MyProject/MyApp/build.gradle:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.6.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.0"

    defaultConfig {
        minSdkVersion 10
        targetSdkVersion 19
    }
}

dependencies {
    compile project(':external:TheLibrary')
    /* other dependencies */
}

MyProject/settings.gradle:

include ':external:TheLibrary', ':MyApp'
Community
  • 1
  • 1

1 Answers1

0

Try adding latest version of gradle that is avaliable.

Put in your build.gradle located on root (MyProject in ur case)

dependencies {
    classpath 'com.android.tools.build:gradle:0.9.+'
}

Plus you don't need to specify gradle for each project. You can put it in your main build.gradle and other libs will read from it. Mine build.gradle looks like that in listing below. And for your case build.gradle will be in root directory MyProject. So you want to edit global build.gradle not the ones that are inside modules (MyApp and TheLibrary). You can delate your claspath to gradles in those modules - make only one globaly.

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.9.+'
    }
}

 allprojects {
    repositories {
        mavenCentral()
    }
}

Put in your gradle wrapper:

distributionUrl=http\://services.gradle.org/distributions/gradle-1.11-all.zip

And I think that build tools might be a main problem here. Make every of your lib projects to have the same build tool variant as your main project so, swtich from:

compileSdkVersion 17
buildToolsVersion "17.0.0"

to:

compileSdkVersion 19
buildToolsVersion "19.0.0"

And btw. there is 19.0.3 avaliable.

F1sher
  • 7,140
  • 11
  • 48
  • 85