【问题标题】:Implementing Swagger-codegen project - Error:(23, 17) Failed to resolve: junit:junit:4.12实施 Swagger-codegen 项目 - 错误:(23, 17) 无法解决:junit:junit:4.12
【发布时间】:2016-12-02 23:16:30
【问题描述】:

嗨,我是 swagger 的新手,自从我为 Android 开发以来已经有一段时间了 - 还没有完全理解 gradle 文件等。

由于依赖于 JUnit 4.12,我陷入了这个问题

我有一个项目不想与使用 swagger-codegen 生成的项目创建的项目合并

我已经导入了源代码,但现在我无法解决 Junit:2.14

无法解决:junit:junit:4.12

我尝试将它添加到 gradlebuild 不同的方式中,并阅读了一些你应该将 maven 添加为存储库的地方。已导入 pom.xml。

在 swagger-codegen 项目中,有一个名为 build.sbt 的文件不在我的项目中。跟那个文件有关系吗?不太明白为什么还要有另一个构建文件。

应用插件:'com.android.application'

android {
    compileSdkVersion 23
  buildToolsVersion "24.0.0"
defaultConfig {
    applicationId "com.xxxxx.app.xxxxx"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"


}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
       }
   }
}

buildscript {
   repositories {
       jcenter()
       maven { url 'http://repo1.maven.org/maven2' }
  }

dependencies {
    classpath 'com.android.tools.build:gradle:1.2.3'
  }
}

dependencies {
  compile fileTree(include: ['*.jar'], dir: 'libs')
  compile 'com.google.android.gms:play-services-gcm:7.8.0'
  compile 'com.android.support:appcompat-v7:23.4.0'
  compile 'com.android.support:design:23.4.0'
  androidTestCompile 'junit:junit:4.12'

 }

【问题讨论】:

    标签: android junit swagger-codegen


    【解决方案1】:

    如果您还没有使用Swagger Codegen 2.2.0(最近发布的)生成Android API客户端,请使用最新的稳定版本默认生成带有Volley库(而不是HttpClient)的Android API客户端(Android API客户端带有HttpClient 不再积极维护)。

    您可能还会发现此常见问题解答很有用:https://github.com/swagger-api/swagger-codegen/wiki/FAQ#how-can-i-generate-an-android-sdk

    关于您对 build.sbt 文件的问题,该文件由另一个名为 sbt 的构建工具使用,主要由 Scala 使用。

    【讨论】:

    • 我如何知道我运行的是什么版本?在 README.md 中不是很清楚?如果 2.2.0 是稳定版,则认为它是最新的 - 我大约五天前下载了它,而 2.2.0 是 13 天前发布的
    【解决方案2】:

    你还需要junit吗?

    如果是这样,那么我认为 Gradle 的正确行是这个(删除编译的 android 部分)

    testCompile 'junit:junit:4.12'
    

    【讨论】:

    • 是的,我最终所做的就是移除了 JUnit。谢谢。但我在想,我在依赖方面遇到了更多问题,也许将我的项目导入到 swagger 项目中会更轻松......
    • 我没有说要删除我说的使用这一行代替的依赖
    • 我已经尝试删除“android”,但没有帮助。我现在有另一个问题,正如我所说,我想知道我是否以某种方式做这个根本性的错误/倒退
    • 在一个新问题stackoverflow.com/questions/38694553/…中询问了这个问题
    【解决方案3】:

    buildscriptrepositories 块,但 dependencies 需要一个块:

      repositories {
           mavenCentral()
      }
    

    Junit 4.12 托管在此处的 MavenCentral 上:https://mvnrepository.com/artifact/junit/junit

    【讨论】:

      猜你喜欢
      • 2015-12-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-24
      • 2016-01-03
      • 1970-01-01
      • 2016-02-01
      相关资源
      最近更新 更多