Implementing Swagger-codegen project - Error:(23, 17) Failed to resolve: junit:junit:4.12

梦想的初衷 提交于 2019-12-25 07:17:07

问题


Hi Im new to swagger and It was a while since I developed for Android - haven't understood all with the gradle files etc.

Im stuck with this problem with dependency to the JUnit 4.12

I have a project that I wan't to merge with a project created with a project generated with swagger-codegen

I have imported the source but now I'm stuck with getting to resolve Junit:2.14

Failed to resolve: junit:junit:4.12

I have tried to add it to gradlebuild diffrent ways and read some where that you sould add maven as repositiory. Have imported the pom.xml.

In the swagger-codegen project there's a file called build.sbt thats not in my project. Does it have anything to do with that file? Don't really understand why there should be yet another build file.

apply plugin: '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'

 }

回答1:


Please use Swagger Codegen 2.2.0 (recently released) to generate the Android API client if you've not done so as the latest stable version generates Android API client with the Volley library (instead of HttpClient) by default (Android API client with HttpClient is no longer actively maintained).

You may also find this FAQ useful: https://github.com/swagger-api/swagger-codegen/wiki/FAQ#how-can-i-generate-an-android-sdk

About your question on the build.sbt file, that's used by another build tool called sbt, mainly used by Scala.




回答2:


Do you even need junit?

If so, then I think the correct line of Gradle is this (drop the android piece of the compile)

testCompile 'junit:junit:4.12'



回答3:


You have the repositories block for the buildscript but you need one for the dependencies:

  repositories {
       mavenCentral()
  }

Junit 4.12 is hosted on MavenCentral here: https://mvnrepository.com/artifact/junit/junit.



来源:https://stackoverflow.com/questions/38638467/implementing-swagger-codegen-project-error23-17-failed-to-resolve-junitj

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!