2015-05-27 5 views
2

Я загружаю Robolectric Samples и импортирован Android Studio (версия 1.2.1.1). Под android-api-19 прилагаю зависимости, как выглядит следующим образом:Некоторые артефакты пропущены при использовании Android Studio (Gradle) и Robolectric

dependencies { 
testCompile "junit:junit:4.10" 
testCompile "org.json:json:20080701" 
testCompile "org.ccil.cowan.tagsoup:tagsoup:1.2" 
testCompile "org.assertj:assertj-core:1.7.0" 
testCompile "org.robolectric:robolectric:${robolectricVersion}" 
testCompile "org.robolectric:android-all:4.4_r1-robolectric-1" 
testCompile "org.robolectric:shadows-core:3.0-rc2" 

} 

Я могу видеть библиотеки json, tagsoup, shadows-core и android-all по Project зрения. Я также вижу их в каталоге $ {GRADLE_HOME} /caches/modules-2/files-2.1. Но когда я запускаю проект с помощью теста Gradle, возникают ошибки:


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.robolectric:android-all:jar:4.4_r1-robolectric-1 

    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.4_r1-robolectric-1 -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.4_r1-robolectric-1 -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.4_r1-robolectric-1 

3) 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 

4) org.robolectric:shadows-core:jar:19:3.0-rc2 

    Try downloading the file manually from the project website. 

    Then, install it using the command: 
     mvn install:install-file -DgroupId=org.robolectric -DartifactId=shadows-core -Dversion=3.0-rc2 -Dclassifier=19 -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=shadows-core -Dversion=3.0-rc2 -Dclassifier=19 -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:shadows-core:jar:19:3.0-rc2 

---------- 
4 required artifacts are missing. 

Любое предложение?

+0

У вас есть определение репозиториев в файле build.gradle? –

+0

Да @AlexFlorescu, это мои конфиги зависимостей: ' buildscript { репозитории { jcenter() } зависимости { классов "com.android.tools.build:gradle:1.2.3" }} репозитории { maven {url "https://oss.sonatype.org/content/repositories/snapshots"} mavenLocal() mavenCentral() } ' – Hicto

ответ

0

Если вы посмотрите на сообщение об ошибке, вы можете просмотреть его репозиторий Maven. Я смог решить эту проблему, обновив файл settings.xml в моем каталоге ~/.m2.

0

Проблема для меня была в рабочем каталоге в конфигурациях прогона. Он указывал на неправильный каталог.

Выберите «Выполнить», а затем «Изменить конфигурации ...». Используйте зеленый знак + в верхнем левом углу, чтобы добавить новую конфигурацию запуска и выберите Android JUnit. Сделайте конфигурацию запуска JUnit следующим образом: enter image description here

При использовании класса пути модуля выберите модуль приложения вашего приложения Android. В качестве рабочего каталога используйте каталог вашего модуля приложения. Класс - это файл, содержащий ваши модульные тесты (в этом случае ваш класс ctivityTest).

Смежные вопросы