0

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'

 }
emmanuel2004
  • 117
  • 2
  • 14

3 Answers3

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.

William Cheng
  • 10,137
  • 5
  • 54
  • 79
  • How do I find out what version Im running? Not really clear in README.md? Think it is the latest if 2.2.0 is the stable one - I downloaded it about five days ago and 2.2.0 was released 13 days ago – emmanuel2004 Jul 30 '16 at 14:55
0

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'
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
  • Yeah that what I ended up doing - removing JUnit. Thanks. But Im thinking, I got more problems with dependency and maybe it would be more painless to import my project into the swagger project... – emmanuel2004 Jul 30 '16 at 14:39
  • I didn't say to remove the dependency I said use this line instead – OneCricketeer Jul 30 '16 at 17:02
  • I already tried to drop "android", but it didn't help. I have another issue now and as I said I'm wondering if I'm doing this fundamental wrong/ backwards somehow – emmanuel2004 Aug 01 '16 at 11:16
  • Asked about it in a new question http://stackoverflow.com/questions/38694553/import-swagger-codegen-project-into-existing-android-project – emmanuel2004 Aug 01 '16 at 12:19
0

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.

Jared Burrows
  • 54,294
  • 25
  • 151
  • 185