I am using Android Studio 1.2 and Windows 7
When running a robolectric test following this example:
@RunWith(CustomRobolectricRunner.class)
@Config(emulateSdk = 21, reportSdk = 21, constants = BuildConfig.class)
public class PasswordProviderTest{
@Test
public void testGetPassword() throws Exception {
Activity activity = Robolectric.setupActivity(LoginActivity.class);
}
@Test
public void testSetPassword() throws Exception {
}
}
test result or more the error stacktrace:
Unable to resolve artifact: Unable to get dependency information: Unable to read the metadata file for artifact 'org.robolectric:android-all:jar': Cannot find parent: org.sonatype.oss:oss-parent for project: org.robolectric:android-all:jar:5.0.0_r2-robolectric-1 for project org.robolectric:android-all:jar:5.0.0_r2-robolectric-1
org.robolectric:android-all:jar:5.0.0_r2-robolectric-1
from the specified remote repositories:
sonatype (https://oss.sonatype.org/content/groups/public/),
central (http://repo1.maven.org/maven2)
Path to dependency:
1) org.apache.maven:super-pom:pom:2.0
at org.apache.maven.artifact.ant.DependenciesTask.doExecuteResolution(DependenciesTask.java:268)
at org.apache.maven.artifact.ant.DependenciesTask.doExecute(DependenciesTask.java:168)
at org.apache.maven.artifact.ant.AbstractArtifactTask.execute(AbstractArtifactTask.java:751)
at org.robolectric.internal.dependency.MavenDependencyResolver.getLocalArtifactUrls(MavenDependencyResolver.java:40)
at org.robolectric.internal.dependency.CachedDependencyResolver.getLocalArtifactUrls(CachedDependencyResolver.java:42)
at org.robolectric.RobolectricTestRunner.createRobolectricClassLoader(RobolectricTestRunner.java:151)
at org.robolectric.RobolectricTestRunner.createSdkEnvironment(RobolectricTestRunner.java:122)
at org.robolectric.RobolectricTestRunner$3.create(RobolectricTestRunner.java:285)
at org.robolectric.internal.EnvHolder.getSdkEnvironment(EnvHolder.java:18)
at org.robolectric.RobolectricTestRunner.getEnvironment(RobolectricTestRunner.java:283)
at org.robolectric.RobolectricTestRunner.access$300(RobolectricTestRunner.java:50)
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:193)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:168)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:86)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:49)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:69)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:105)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.messaging.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:360)
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.maven.artifact.resolver.ArtifactResolutionException: Unable to get dependency information: Unable to read the metadata file for artifact 'org.robolectric:android-all:jar': Cannot find parent: org.sonatype.oss:oss-parent for project: org.robolectric:android-all:jar:5.0.0_r2-robolectric-1 for project org.robolectric:android-all:jar:5.0.0_r2-robolectric-1
org.robolectric:android-all:jar:5.0.0_r2-robolectric-1
from the specified remote repositories:
sonatype (https://oss.sonatype.org/content/groups/public/),
central (http://repo1.maven.org/maven2)
Path to dependency:
1) org.apache.maven:super-pom:pom:2.0
at org.apache.maven.artifact.resolver.DefaultArtifactCollector.recurse(DefaultArtifactCollector.java:430)
at org.apache.maven.artifact.resolver.DefaultArtifactCollector.collect(DefaultArtifactCollector.java:74)
at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolveTransitively(DefaultArtifactResolver.java:316)
at org.apache.maven.artifact.ant.DependenciesTask.doExecuteResolution(DependenciesTask.java:263)
... 46 more
Caused by: org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException: Unable to read the metadata file for artifact 'org.robolectric:android-all:jar': Cannot find parent: org.sonatype.oss:oss-parent for project: org.robolectric:android-all:jar:5.0.0_r2-robolectric-1 for project org.robolectric:android-all:jar:5.0.0_r2-robolectric-1
at org.apache.maven.project.artifact.MavenMetadataSource.retrieveRelocatedProject(MavenMetadataSource.java:200)
at org.apache.maven.project.artifact.MavenMetadataSource.retrieveRelocatedArtifact(MavenMetadataSource.java:94)
at org.apache.maven.artifact.resolver.DefaultArtifactCollector.recurse(DefaultArtifactCollector.java:387)
... 49 more
Caused by: org.apache.maven.project.ProjectBuildingException: Cannot find parent: org.sonatype.oss:oss-parent for project: org.robolectric:android-all:jar:5.0.0_r2-robolectric-1 for project org.robolectric:android-all:jar:5.0.0_r2-robolectric-1
at org.apache.maven.project.DefaultMavenProjectBuilder.assembleLineage(DefaultMavenProjectBuilder.java:1396)
at org.apache.maven.project.DefaultMavenProjectBuilder.buildInternal(DefaultMavenProjectBuilder.java:823)
at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromRepository(DefaultMavenProjectBuilder.java:255)
at org.apache.maven.project.artifact.MavenMetadataSource.retrieveRelocatedProject(MavenMetadataSource.java:163)
... 51 more
Caused by: org.apache.maven.project.ProjectBuildingException: POM 'org.sonatype.oss:oss-parent' not found in repository: Unable to download the artifact from any repository
org.sonatype.oss:oss-parent:pom:7
from the specified remote repositories:
sonatype (https://oss.sonatype.org/content/groups/public/),
central (http://repo1.maven.org/maven2)
for project org.sonatype.oss:oss-parent
at org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepository(DefaultMavenProjectBuilder.java:605)
at org.apache.maven.project.DefaultMavenProjectBuilder.assembleLineage(DefaultMavenProjectBuilder.java:1392)
... 54 more
Caused by: org.apache.maven.artifact.resolver.ArtifactNotFoundException: Unable to download the artifact from any repository
org.sonatype.oss:oss-parent:pom:7
from the specified remote repositories:
sonatype (https://oss.sonatype.org/content/groups/public/),
central (http://repo1.maven.org/maven2)
at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:228)
at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:90)
at org.apache.maven.pr
oject.DefaultMavenProjectBuilder.findModelFromRepository(DefaultMavenProjectBuilder.java:558)
... 55 more
Caused by: org.apache.maven.wagon.ResourceDoesNotExistException: Unable to download the artifact from any repository
at org.apache.maven.artifact.manager.DefaultWagonManager.getArtifact(DefaultWagonManager.java:404)
at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:216)
... 57 more
gradle build dependencies:
testCompile 'junit:junit:4.12'
testCompile "org.mockito:mockito-core:1.9.5"
testCompile 'org.apache.maven:maven-ant-tasks:2.1.3'
testCompile "org.robolectric:robolectric:3.0-rc2"
I find out that the resource, robolectric try to get ,is not avaible. When following the url it trys to get it: https://oss.sonatype.org/content/groups/public/org/sonatype/oss/oss-parent/
there is no oss 7. Why does robolectrics try to get a resource that is not there? And how to get it to work?
This seems to be a proxy problem. When behind proxy you have to specify proxy settings for maven at {userHome}/.m2/settings.xml
my settings.xml looks now like:
<settings>
<proxies>
<proxy>
<active>true</active>
<host>proxy.host</host>
<port>3128</port>
</proxy>
</proxies>
</settings>
below not working !!
<settings>
<proxies>
<proxy>
<id>proxy-https</id>
<active>true</active>
<protocol>https</protocol>
<host>proxy.host</host>
<port>3128</port>
</proxy>
<proxy>
<id>proxy-http</id>
<active>true</active>
<protocol>http</protocol>
<host>proxy.host</host>
<port>3128</port>
</proxy>
</proxies>
</settings>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With