0

I've got an old Android project with the following build.gradle file:

apply plugin: 'com.android.application'

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

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 116
    }
}

dependencies {
    //compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'org.apache.commons:commons-lang3:3.4'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:support-v4:23.1.1'
}

Syncing the project with gradle files results in:

Failed to resolve org.apache.commons:commons-lang3:3.4

But, I think I've got the syntax correct according to this:

https://search.maven.org/#artifactdetails%7Corg.apache.commons%7Ccommons-lang3%7C3.4%7Cjar

Can anyone tell me what I'm missing here?

N.B. if I download the jar and put it in my project's libs directory then uncomment the fileTree line everything works, though I am told that I am not supposed to be doing this.

knirirr
  • 1,860
  • 4
  • 23
  • 37

1 Answers1

-1

problem is that you are missing this at the top level :You also need repositories and dependencies at the top level for the dependencies for your project itself.For more information you can see these solutions commas error and also here .

apply plugin: 'android'

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

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 116
    }
}

repositories{
    mavenCentral()
}


dependencies {
    //compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'org.apache.commons:commons-lang3:3.4'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:support-v4:23.1.1'
}

May it helps and solve problem.

Community
  • 1
  • 1
Shubham Sharma
  • 2,763
  • 5
  • 31
  • 46
  • Thanks. I found that `apply plugin: 'android'` did not resolve the issue; in fact, Android Studio struck it out. However, the first link you specified did result in a fix, i.e. the use of '+' rather than specifying version number in the compile string. – knirirr Aug 22 '16 at 11:32