1

I'm only just starting with Android development so I'm sure this is incredibly basic and a dumb question, but I'm getting the following error when I try and include a library to use in my code with Gradle:

Gradle 'MyApp' project refresh failed: You are using an old, unsupported version of Gradle. Please use version 1.6 or greater.

The library I'm trying to use is ION. All I've tried so far is adding the following lines into the build.gradle file.

dependencies {
    compile 'com.koushikdutta.ion:ion:1.1.5'
}

Which I guessed at based on this section of Koush's GitHub account, but what else do I need to do? Still download the jar and put it somewhere? I have looked at other questions/searched for guides on the basics of Gradle, but bizarrely I can't find a solid, definitive answer.

And how do I upgrade Gradle? Can it be done from within Android studio? I'm using Android Studio 0.2.13 on Windows 7 64bit:

SOLUTION: - Make sure you're putting the dependencies in the correct build.gradle file! Doh! It should be in the one just above your src folder, not the root!

Android Studio Version

BT643
  • 3,495
  • 5
  • 34
  • 55
  • 1
    Honestly, if you are "just starting with Android development", you should not be using Android Studio, or even the new Gradle-based build system, at this time, IMHO. Wait for them to be released in final form. – CommonsWare Oct 17 '13 at 21:28
  • 1
    I'm just learning for fun, not making some production software that needs to be completed within x months :) Seems pointless getting into habits with Eclipse/ADT only to change 6 months down the line when Android Studio is more stable. – BT643 Oct 17 '13 at 21:29
  • @BT643, yeah, just go with Android Studio if that is what you prefer. After some initial hassle (mostly due to having to support Eclipse project structure), it's working fine for me. And of course Android Studio comes with so many awesome features (familiar from IDEA and other JetBrains IDEs) that are missing from Eclipse. – Jonik Oct 18 '13 at 15:43

1 Answers1

2

Make sure that your buildscript contains the classpath with "gradle:0.5.+". Afterwards, navigate to the root directory of your project (one directory level above the build.gradle file) and (in the command line) run "./gradlew clean"

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

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 18
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 18
    }

    sourceSets {
        main {
            manifest.srcFile 'MyApp\src\main\AndroidManifest.xml'
        }
    }
}

dependencies {
    compile "com.koushikdutta.ion:ion:1.1.5"
}
iamreptar
  • 1,461
  • 16
  • 29
  • Hmm, that got me a different error at least: `Gradle 'MyApp' project refresh failed: Main Manifest missing from S:\Development\Android\MyApp\src\main\AndroidManifest.xml` The app compiles and runs fine so far (if I take out the Gradle stuff), so the AndroidManifest *is* in that location and seems to work fine. – BT643 Oct 17 '13 at 21:52
  • Add [sourceSets](http://stackoverflow.com/questions/17096983/android-studio-manifest-missing-error) in the android section to define the location of your manifest file. – iamreptar Oct 17 '13 at 22:02
  • Wow, that was pretty special! I had put it in the wrong build.gradle file! I put it in the root one, not the one just above the src folder. Doh! Still haven't actually got ION working, but at least compiles without errors now... thanks! – BT643 Oct 19 '13 at 20:59