Could not resolve active Android dependency in Gradle when Active Android is included in the library

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

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

and add the repository for it like this:

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

However, if I do this in a library project, I get an error message:

 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 add my library module as follows:

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

To remove this error, I must add the repository to the main application module 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 repositories defined only in the library project, without the need to add the repository to the main application module? I just want the library module to look after itself.

+5
source share
1 answer

I also ran into this error and liked the solution.

You need to edit the build.gradle the 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.

0
source

Source: https://habr.com/ru/post/1213073/


All Articles