android - 如何在没有最新版本的 maven Artifact 的情况下使用 Gradle 构建 android 应用程序?

标签 android maven gradle

我有使用 Gradle 构建的应用程序,它需要 maven 模块 fs .我的安卓应用需要版本 1.1 (存在于本地 maven 存储库中)但它不是本地 maven 存储库中模块的最新版本(版本 1.2 也在本地 maven 存储库中):

compile 'name.antonsmirnov.fs:fs:1.1'

尝试构建 android 应用程序时出现错误:
Executing tasks: [clean, :app:compileDebugSources, :app:compileDebugAndroidTestSources]

Configuration on demand is an incubating feature.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
   > Could not resolve name.antonsmirnov.fs:fs:1.1.
     Required by:
         Ad_gradle:app:unspecified
      > inconsistent module metadata found. Descriptor: name.antonsmirnov.fs:fs:1.2 Errors: bad version: expected='1.1' found='1.2'
   > Could not resolve name.antonsmirnov.fs:dropbox:1.1.

我如何强制 Gradle 不使用最新版本的 Maven 模块( Artifact )?

PS。还有一个问题:如果我删除文件夹 1.2从本地 maven repo 它没有帮助(所以 gradle 缓存了 1.2 可用并且即使在删除后也不会编译)。

聚苯乙烯。即使我使用“+”作为版本以使 Gradle 获得最新的可用版本,它也无法解决它:
compile "name.antonsmirnov.fs:fs:+"

错误:
* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
   > Could not resolve name.antonsmirnov.fs:fs:+.
     Required by:
         Ad_gradle:app:unspecified
      > inconsistent module metadata found. Descriptor: name.antonsmirnov.fs:fs:1.2 Errors: bad version: expected='1.1' found='1.2'

最佳答案

检查您的应用程序的 gradle 配置,您在其中指定要用于 Maven Artifact 的存储库。根据您的配置,这可能在您的顶层 build.gradle文件或项目的文件(通常为 app/build.gradle 。)您需要添加 mavenLocal为了获取您本地的 Maven Artifact :

repositories {
    mavenLocal()
}

关于android - 如何在没有最新版本的 maven Artifact 的情况下使用 Gradle 构建 android 应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35696864/

相关文章:

java - Android fragment - 无法播放此视频

android - 无法在 onPrepareDialog 中设置复选框状态

java - 使用 context.xml 配置 WebApp 以使用 Tomcat

java - 如何从 spring-boot-starter-parent 中排除特定的依赖项

gradle - Gradle依赖项描述符中的自定义元数据

java - Android 应用程序运行时错误

Android 应用 DeviceAnywhere LogCat

java - 开发本地时 GAE Blob 消失

android - 单元测试失败时停止 gradle 构建

actionbarsherlock - Android Studio 项目无法解析 ActionBarSherlock 导入