我最近从基于Gradle的Android构建系统的maven-android-plugin
迁移到v1.1。在与hamcrest(以及相关的泛型地狱)相关的一些变化之后,我在gradle下运行了基于 Robolectric 的单元测试......但是只有我使用sudo
运行测试gradle命令。
我得到的错误是运行类似于./gradlew testWithGoogleMapsDebug
Unable to resolve artifact: Missing:
Caused by: org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException: Missing:
我检查了本地.m2
repo的权限,并chmod -R 777
修改了回购的根目录以查看它是否有任何影响(它没有)。
我怀疑那里有人知道怎么了傻瓜但是我有点卡住了!
......这是完整的痕迹;
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
----------
...这里是删除了敏感信息的app build.gradle;
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'
}
...我正在运行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"
答案 0 :(得分:0)
所以...运行带有--info
标志的构建突出显示gradle正在尝试在硬盘驱动器的根目录下创建一个.m2
文件夹。它没有这样做的许可(为什么会这样?!)。
所以," WTF"这就是为什么在gradle构建下运行单元测试时,它需要驱动器根目录下的另一个 .m2 repo。迷失了...