5

I have a library project that includes active android using Gradle. To get it to work I have to add

compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'

and add the repository for it like so:

repositories {
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}

However if I do this in the library project, I get the error:

Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
   > Could not find com.michaelpardo:activeandroid:3.1.0-SNAPSHOT.
     Searched in the following locations:
         https://jcenter.bintray.com/com/michaelpardo/activeandroid/3.1.0-SNAPSHOT/maven-metadata.xml
         https://jcenter.bintray.com/com/michaelpardo/activeandroid/3.1.0-SNAPSHOT/activeandroid-3.1.0-SNAPSHOT.pom
         https://jcenter.bintray.com/com/michaelpardo/activeandroid/3.1.0-SNAPSHOT/activeandroid-3.1.0-SNAPSHOT.jar
         file:/Users/user/AndroidSDK/extras/android/m2repository/com/michaelpardo/activeandroid/3.1.0-SNAPSHOT/maven-metadata.xml
         file:/Users/user/AndroidSDK/extras/android/m2repository/com/michaelpardo/activeandroid/3.1.0-SNAPSHOT/activeandroid-3.1.0-SNAPSHOT.pom
         file:/Users/user/AndroidSDK/extras/android/m2repository/com/michaelpardo/activeandroid/3.1.0-SNAPSHOT/activeandroid-3.1.0-SNAPSHOT.jar
         file:/Users/user/AndroidSDK/extras/google/m2repository/com/michaelpardo/activeandroid/3.1.0-SNAPSHOT/maven-metadata.xml
         file:/Users/user/AndroidSDK/extras/google/m2repository/com/michaelpardo/activeandroid/3.1.0-SNAPSHOT/activeandroid-3.1.0-SNAPSHOT.pom
         file:/Users/user/AndroidSDK/extras/google/m2repository/com/michaelpardo/activeandroid/3.1.0-SNAPSHOT/activeandroid-3.1.0-SNAPSHOT.jar
     Required by:
         Condeco:app:unspecified > Condeco:common:unspecified

I am adding my library module like so:

dependencies {
    compile project(':common')
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
}

To remove this error I have to add the repository to the main app module as well in the same way:

repositories {
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}

When I do this the project compiles fine.

Can I get my project to compile with the repositories defined only in the library project without having to add the repository to the main app module? I just want to have the library module look after itself.

MungoRae
  • 1,912
  • 1
  • 16
  • 25

1 Answers1

0

I also faced this error, and the solution goes likes this.

You have to edit build.gradle of android app module.

apply plugin: 'com.android.application'

// Add this block
buildscript {
    repositories {

    }
    dependencies {
    }
}

repositories {
    mavenCentral()
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
// End of this block
android {
   compileSdkVersion 25
   buildToolsVersion "25.0.3"
   ..... //Replace dots with your code
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
    })
    .... //Replace dots with your code
    compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT' //Add this line
}

Hope this helps.

Subin Chalil
  • 3,531
  • 2
  • 24
  • 38