Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not find com.android.support:support-v13:19.0.0

Since the last round of updates I have been getting this error. Gradle absolutely, categorically refuses to find the v13 support library. I have tried the following:

  • installing latest Android Support Repository as well as latest Android support library
  • the first two suggestions from here
  • specifying the latest gradle (0.12.+) in the build script
  • specifying different versions of the v13 library

I can see the jars in the m2repository folder for it. In fact, I can see all of the alternative versions that I have tried.

Here's my build.gradle's:

    buildscript {
        repositories {
            def androidHome = System.getenv("ANDROID_HOME")
            mavenCentral()
            maven {
                url "$androidHome/extras/android/m2repository/"
            }
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:0.12.+'
            classpath 'org.robolectric.gradle:gradle-android-test-plugin:0.9.4'
        }
        ext.compileSdkVersion = 19
        ext.buildToolsVersion = "19.0.3"
        ext.minSdkVersion = 14
        ext.targetSdkVersion = 18
        ext.buildVersion = 8
        ext.codeVersion = 5
    }

    allprojects {
        repositories {
            mavenCentral()
        }
    }

...and then in the main project:

    apply plugin: 'android'
    apply plugin: 'android-test'

    tasks.withType(Compile) {
        options.encoding = 'UTF-8'
    }

    def getVersionCode = { ->
        return getDate()
    }

    def getDate() {
        def date = new Date()
        return date.getTime().toInteger() + 1000000000
    }

    def getVersionName = { ->
        try {
            def stdout = new ByteArrayOutputStream()
            exec {
                commandLine 'git', 'describe', '--tags', '--dirty'
                standardOutput = stdout
            }
            return stdout.toString().trim()
        }
        catch (ignored) {
            return null;
        }
    }

    dependencies {
        compile fileTree(dir: 'libs', include: '*.jar')
        compile 'com.android.support:support-v13:19.0.0'
        compile 'com.android.support:support-v4:19.1.0'
        compile 'com.fasterxml.jackson.core:jackson-databind:2.3.0'

        compile project(':lib-volley')
        compile project(':lib-pulltorefresh')
        compile project(':lib-player')

        androidTestCompile 'org.hamcrest:hamcrest-all:1.3'
        androidTestCompile 'org.mockito:mockito-core:1.9.5'
        androidTestCompile 'junit:junit:4.11'
        androidTestCompile('org.robolectric:robolectric:2.3:jar-with-dependencies') {
            exclude module: 'classworlds'
            exclude module: 'maven-artifact'
            exclude module: 'maven-artifact-manager'
            exclude module: 'maven-error-diagnostics'
            exclude module: 'maven-model'
            exclude module: 'maven-plugin-registry'
            exclude module: 'maven-profile'
            exclude module: 'maven-project'
            exclude module: 'maven-settings'
            exclude module: 'nekohtml'
            exclude module: 'plexus-container-default'
            exclude module: 'plexus-interpolation'
            exclude module: 'plexus-utils'
            exclude module: 'wagon-file'
            exclude module: 'wagon-http-lightweight'
            exclude module: 'wagon-http-shared'
            exclude module: 'wagon-provider-api'
        }
        androidTestCompile 'com.squareup:fest-android:1.0.7'

        testCompile 'org.hamcrest:hamcrest-all:1.3'
        testCompile 'org.mockito:mockito-core:1.9.5'
        testCompile 'junit:junit:4.11'
        testCompile('org.robolectric:robolectric:2.3:jar-with-dependencies') {
            exclude module: 'classworlds'
            exclude module: 'maven-artifact'
            exclude module: 'maven-artifact-manager'
            exclude module: 'maven-error-diagnostics'
            exclude module: 'maven-model'
            exclude module: 'maven-plugin-registry'
            exclude module: 'maven-profile'
            exclude module: 'maven-project'
            exclude module: 'maven-settings'
            exclude module: 'nekohtml'
            exclude module: 'plexus-container-default'
            exclude module: 'plexus-interpolation'
            exclude module: 'plexus-utils'
            exclude module: 'wagon-file'
            exclude module: 'wagon-http-lightweight'
            exclude module: 'wagon-http-shared'
            exclude module: 'wagon-provider-api'
        }
        testCompile 'com.squareup:fest-android:1.0.7'
    }

    android {
        compileSdkVersion rootProject.compileSdkVersion
        buildToolsVersion rootProject.buildToolsVersion

        defaultConfig {
            minSdkVersion rootProject.minSdkVersion
            targetSdkVersion rootProject.targetSdkVersion
            versionCode getVersionCode()
            versionName getVersionName()
        }

    ... # signingConfigs and productFlavors removed

        buildTypes {
            debug {
                packageNameSuffix ".debug"
                versionNameSuffix " debug"
                debuggable true
                jniDebugBuild true
            }
            trial {
                packageNameSuffix ".trial"
                versionNameSuffix " trial"
                signingConfig signingConfigs.debug
                debuggable true
                jniDebugBuild true
            }
            release {
                runProguard false
                proguardFile 'proguard-android.txt'
                proguardFile getDefaultProguardFile('proguard-android.txt')
                debuggable false
                jniDebugBuild false
                signingConfig signingConfigs.release
                zipAlign true
            }
        }

        sourceSets {
            main {
                manifest.srcFile 'AndroidManifest.xml'
                res.srcDirs = ['res']
            }
            trial {
                assets.srcDirs = ['assets']
            }
            release {
                assets.srcDirs = ['assets-release']
            }
            debug {
                assets.srcDirs = ['assets']
            }
            androidTest.setRoot('src/test')
        }

        packagingOptions {
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/DEPENDENCIES'
        }

        lintOptions {
            disable 'ValidFragment'
        }
    }

    if (project.hasProperty('keyAlias')) {
        android.signingConfigs.release.keyAlias = keyAlias
    }

    androidTest {
        include '**/*Test.class'
    }

    apply plugin: 'idea'

    idea {
        module {
            testOutputDir = file(rootProject.testOutputDir)
        }
    }

    task copyDependencies(type: Copy) {
        description = 'Copy dependencies to a libraries folder. Useful for Eclipse'
        ext.libDir = new File(project.projectDir, '/libraries')
        println libDir
        ext.srclibDir = new File(project.projectDir, '/libs')
        println srclibDir
        println 'Adding dependencies from lib directory'
        copy
        {
            from srclibDir
            into libDir
        }
        println 'Adding dependencies from compile configuration'
        for (file in configurations.compile) {
            copy
                    {
                        from file
                        into libDir
                    }
        }
        println 'Adding dependencies from releaseCompile configuration'
        for (file in configurations.releaseCompile) {
            copy
                    {
                        from file
                        into libDir
                    }
        }
        println 'Adding dependencies from debugCompile configuration'
        for (file in configurations.debugCompile) {
            copy
                    {
                        from file
                        into libDir
                    }
        }

        println 'Adding dependencies from androidTestCompile configuration'
        for (file in configurations.androidTestCompile) {
            copy
                    {
                        from file
                        into libDir
                    }
        }
    }

Any ideas how to get Gradle to see the v13 library would be greatly appreciated.

like image 855
Myles Bennett Avatar asked Jul 10 '14 11:07

Myles Bennett


1 Answers

Solved it.

The error was occurring inside the copyDependencies task at the start of the for loops. It seems that gradle won't use sdk/extras/m2repository to resolve dependancies. The following should have worked...

repositories {
     def androidHome = System.getenv("ANDROID_HOME")
     mavenCentral()
     maven {
         url "$androidHome/extras/android/m2repository/"
     }
}

... but didn't. I think there is an issue with gradle not picking up ANDROID_HOME. In the end I copied the whole of android/m2repository into .m2/repository and then used mavenLocal() in the parent build script instead of trying to access the sdk repository.

Another approach could have been to add exclude module: 'support-v13' to the robolectric dependancy exclusions, but project needed it elsewhere.

like image 54
Myles Bennett Avatar answered Oct 27 '22 01:10

Myles Bennett