当Active Android包含在库中时,无法解决Gradle中的活动Android依赖关系

Mun*_*Rae 5 android gradle activeandroid

我有一个库项目,包括使用Gradle的活动android.为了让它工作,我必须添加

compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
Run Code Online (Sandbox Code Playgroud)

并为它添加存储库,如下所示:

repositories {
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
Run Code Online (Sandbox Code Playgroud)

但是,如果我在库项目中执行此操作,则会收到错误:

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
Run Code Online (Sandbox Code Playgroud)

我正在添加我的库模块,如下所示:

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

要删除此错误,我必须以相同的方式将存储库添加到主应用程序模块:

repositories {
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
Run Code Online (Sandbox Code Playgroud)

当我这样做时,项目编译得很好.

我是否可以使用仅在库项目中定义的存储库来编译我的项目,而无需将存储库添加到主应用程序模块?我只想让库模块照顾好自己.

Sub*_*lil 0

我也遇到了这个错误,解决方案是这样的。

您必须编辑build.gradleandroidapp模块。

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
}
Run Code Online (Sandbox Code Playgroud)

希望这可以帮助。