emmanuel2004 emmanuel2004 - 4 months ago 31
Android Question

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

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'

}

Answer

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'