I've recently migrated from the maven-android-plugin
to v1.1 of the Gradle-based Android build system. After a number of changes associated with hamcrest (and associated generics hell) I have my Robolectric based unit tests running under gradle... but only if I run the testing gradle commands with sudo
.
The error I get back having run a command akin to ./gradlew testWithGoogleMapsDebug
Unable to resolve artifact: Missing:
Caused by: org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException: Missing:
I've checked the local .m2
repo's permissions and chmod -R 777
'ed the root of the repo to see if that has any affect (it didn't).
I suspect someone out there knows whats up but alas I'm a bit stuck!
...here is the full trace;
Unable to resolve artifact: Missing:
----------
1) org.ccil.cowan.tagsoup:tagsoup:jar:1.2
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=org.ccil.cowan.tagsoup -DartifactId=tagsoup -Dversion=1.2 -Dpackaging=jar -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=org.ccil.cowan.tagsoup -DartifactId=tagsoup -Dversion=1.2 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
Path to dependency:
1) org.apache.maven:super-pom:pom:2.0
2) org.ccil.cowan.tagsoup:tagsoup:jar:1.2
2) org.json:json:jar:20080701
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=org.json -DartifactId=json -Dversion=20080701 -Dpackaging=jar -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=org.json -DartifactId=json -Dversion=20080701 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
Path to dependency:
1) org.apache.maven:super-pom:pom:2.0
2) org.json:json:jar:20080701
3) org.robolectric:android-all:jar:4.3_r2-robolectric-0
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=org.robolectric -DartifactId=android-all -Dversion=4.3_r2-robolectric-0 -Dpackaging=jar -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=org.robolectric -DartifactId=android-all -Dversion=4.3_r2-robolectric-0 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
Path to dependency:
1) org.apache.maven:super-pom:pom:2.0
2) org.robolectric:android-all:jar:4.3_r2-robolectric-0
----------
...and here is the app build.gradle with sensitive information removed;
apply plugin: 'com.android.application'
android {
compileSdkVersion 17
buildToolsVersion "21.1.2"
defaultConfig {
// Keep original packaging package path.
applicationId "my.app.id"
minSdkVersion 11
targetSdkVersion 19
versionCode 25
versionName "2.4.0"
multiDexEnabled true
}
sourceSets {
androidTest.setRoot('src/test')
}
signingConfigs {
debug {
storeFile file("debug.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
release {
// Release signing detail.
}
}
buildTypes {
debug {
debuggable true
signingConfig signingConfigs.debug
pseudoLocalesEnabled true
}
release {
minifyEnabled false
signingConfig signingConfigs.release
}
}
productFlavors {
withGoogleMaps {
// Flavour-based config
}
withOsm {
// Flavour-based config
}
}
lintOptions {
abortOnError false
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_7
}
}
repositories {
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
dependencies {
compile project(':viewPagerIndicator')
compile 'com.nineoldandroids:library:2.4.0'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'joda-time:joda-time:2.7'
compile 'de.keyboardsurfer.android.widget:crouton:1.8.5@aar'
compile 'com.squareup.dagger:dagger:1.2.1'
compile 'com.android.support:support-v4:22.0.0'
compile 'com.google.guava:guava:18.0'
compile 'com.github.amlcurran.showcaseview:library:5.1.1-SNAPSHOT'
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
withGoogleMapsCompile 'com.google.android.gms:play-services-location:7.0.0'
withGoogleMapsCompile 'com.google.android.gms:play-services-maps:7.0.0'
withOsmCompile 'org.osmdroid:osmdroid-android:4.1'
withOsmCompile 'org.osmdroid:osmbonuspack:4.4'
withOsmCompile 'org.slf4j:slf4j-android:1.7.7'
// Test dependencies.
testCompile 'org.hamcrest:hamcrest-core:1.3'
testCompile 'org.robolectric:robolectric:2.4'
testCompile('org.mockito:mockito-core:1.9.5') {
exclude group: 'org.hamcrest'
}
testCompile 'junit:junit:4.12'
testCompile 'com.google.guava:guava:18.0'
provided 'com.squareup.dagger:dagger-compiler:1.2.1'
}
configurations {
// Avoid gradle warnings.
all*.exclude module: 'commons-logging'
all*.exclude module: 'httpclient'
}
...and I'm running Maven 3.1.1;
Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 16:22:22+0100)
Maven home: /Users/me/Dropbox/Maven
Java version: 1.7.0_45, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.10.1", arch: "x86_64", family: "mac"
So... running the build with the --info
flag highlighted that gradle is trying to create a .m2
folder at the root of the hard drive. It doesn't have permission to do that (why would it?!).
So, the "WTF" moment was why when running unit tests under a gradle build does it need another .m2 repo at the root of the drive. Lost on that...