git 使用 gradle (Android Studio) 和本地 maven repo 时无法构建应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20911665/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 09:31:51  来源:igfitidea点击:

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

androidgitmavengradleandroid-studio

提问by fooforever

I am trying to include the library Slikand Cards-UIin 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:

我正在尝试在我的应用程序中包含库SlikCards-UI,我正在使用 android studio 和 gradle 来构建。没有这个,应用程序构建得很好,但添加依赖项会使构建失败。查看构建的调试日志,它似乎没有在本地存储库中查找 arr 文件。我可以看到文件在那里,我已经按照 github wiki 页面上的教程进行安装,并且工作正常。错误是:

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

这是我的 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

谷歌播放服务依赖项工作正常,并按预期从 maven 中央仓库中找到。任何人的想法?谢谢

回答by Scott Barta

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

这是错误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:

如果您查看该错误中的评论 #3,则有一个解决方法。试试看是否有帮助:

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 存储库的 Gradle 1.9 中的错误。

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

现在的解决方法是使用

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

instead of mavenLocal()

而不是 mavenLocal()

回答by A.Infante

In Android Studio 0.4.6 using mavenLocal works fine:

在 Android Studio 0.4.6 中使用 mavenLocal 工作正常:

repositories {
    mavenCentral()
    mavenLocal()
}

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

在 Preferences >> Maven 上检查并配置您的 Maven 安装,以确保它指向您的本地存储库。

I hope this update helps newcomers.

我希望此更新对新人有所帮助。