Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot build app when using gradle (Android Studio) and local maven repo

I am trying to include the library Slik and Cards-UI in my app, I'm using android studio and gradle to build. The app builds fine without this but adding the dependency make the build fail. Looking at the debug log of the build it doesn't seem to be looking in the local repo for the arr file. I can see the files are there and I have followed the tutorial on the github wiki page for the install and that works fine. The error is:

A problem occurred configuring project ':climbtrack'.
> Could not resolve all dependencies for configuration ':climbtrack:_debugCompile'.
   > Could not find com.afollestad.cardsui:library:1.0-SNAPSHOT.
     Required by:
         ClimbTrack:climbtrack:unspecified
   > Could not find com.afollestad.silk:library:1.0-SNAPSHOT.
     Required by:
         ClimbTrack:climbtrack:unspecified

Here is my build.gradle

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

repositories {
    mavenLocal()
    mavenCentral()
}

android {
    compileSdkVersion 18
    buildToolsVersion "19.0.0"

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.google.android.gms:play-services:4.0.30'
    compile 'com.afollestad.cardsui:library:1.0-SNAPSHOT'
    compile 'com.afollestad.silk:library:1.0-SNAPSHOT'
}

The google play services dependency works fine and is found from the maven central repo as expected. Any ideas anyone? Thanks

like image 574
fooforever Avatar asked Jan 03 '14 19:01

fooforever


People also ask

Does Gradle use Maven local repository?

gradle - Gradle does not use the Maven Local Repository for a new dependency - Stack Overflow. Stack Overflow for Teams – Start collaborating and sharing organizational knowledge.

Does Gradle have local repository?

Gradle can consume dependencies available in the local Maven repository. Declaring this repository is beneficial for teams that publish to the local Maven repository with one project and consume the artifacts by Gradle in another project. Gradle stores resolved dependencies in its own cache.


2 Answers

This is bug https://code.google.com/p/android/issues/detail?id=63908

If you look at comment #3 in that bug, there's a workaround. Try it and see if it helps:

This appears to be a bug in Gradle 1.9 with local Maven repositories.

See https://plus.google.com/109385828142935151413/posts/hF7W59uZ7rX

The workaround for now is to use

 maven {   url "${System.env.HOME}/.m2/repository" } 

instead of mavenLocal()

like image 94
Scott Barta Avatar answered Sep 28 '22 03:09

Scott Barta


In Android Studio 0.4.6 using mavenLocal works fine:

repositories {
    mavenCentral()
    mavenLocal()
}

Check and configure your Maven installation on Preferences >> Maven to ensure it points to your local repository.

I hope this update helps newcomers.

like image 35
A.Infante Avatar answered Sep 28 '22 02:09

A.Infante