Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle robolectric project works on OSX computer but not on Linux

I'm using the same version of Gradle, 1.7 jdk thus not exactly the same version.

The main complain of the testing is :

java.lang.NoClassDefFoundError: org/apache/maven/artifact/ant/DependenciesTask Caused by: java.lang.ClassNotFoundException: org.apache.maven.artifact.ant.DependenciesTask

I've tried to clean gradle cache in order to re download all dependencies. Also i've tried to clean the project.

This didn't work.

What variables can affect the execution of a gradle test ?

To me there is:

  • Gradle itself
  • Java version of the sdk
  • Internet connections problems

What else can be interfering ? Are plugin versions platform dependant ?

Executing task ':robolectric-tests:test' (up-to-date check took 0.432 secs) due to:
  Output file /home/ec2-user/repositories/MyProject/robolectric-tests/build/test-results has changed.
  Output file /home/ec2-user/repositories/MyProject/robolectric-tests/build/reports/tests has changed.
  Output file /home/ec2-user/repositories/MyProject/robolectric-tests/build/test-results/binary/test has changed.
Starting process 'Gradle Test Executor 1'. Working directory: /home/ec2-user/repositories/MyProject/robolectric-tests Command: /usr/java/jdk1.7.0_72/bin/java -Djava.security.manager=jarjar.org.gradle.process.internal.child.BootstrapSecurityManager -Dfile.encoding=UTF-8 -Duser.country=ES -Duser.language=ca -Duser.variant -ea -cp /home/ec2-user/.gradle/caches/2.3/workerMain/gradle-worker.jar jarjar.org.gradle.process.internal.launcher.GradleWorkerMain 'Gradle Test Executor 1'
Successfully started process 'Gradle Test Executor 1'
Gradle Test Executor 1 started executing tests.
Gradle Test Executor 1 finished executing tests.

com.tubtale.MyProject.robolectrictests.tests.RobTMyAndroidClassTest > testWhenActivityCreatedHelloTextViewIsVisible2 FAILED
    java.lang.NoClassDefFoundError: org/apache/maven/artifact/ant/DependenciesTask

        Caused by:
        java.lang.ClassNotFoundException: org.apache.maven.artifact.ant.DependenciesTask

com.tubtale.MyProject.robolectrictests.tests.RobTMyAndroidClassTest > testWhenActivityCreatedHelloTextViewIsVisible FAILED
    java.lang.NoClassDefFoundError: org/apache/maven/artifact/ant/DependenciesTask

2 tests completed, 2 failed
Finished generating test XML results (0.217 secs) into: /home/ec2-user/repositories/MyProject/robolectric-tests/build/test-results
Generating HTML test report...
Finished generating test html results (0.11 secs) into: /home/ec2-user/repositories/MyProject/robolectric-tests/build/reports/tests
:robolectric-tests:test FAILED
:robolectric-tests:test (Thread[main,5,main]) completed. Took 4.005 secs.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':robolectric-tests:test'.
> There were failing tests. See the report at: file:///home/ec2-user/repositories/MyProject/robolectric-tests/build/reports/tests/index.html

* Try:
Run with --debug option to get more log output.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':robolectric-tests:test'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:306)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:88)
    at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
    at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
    at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:68)
    at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:55)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:149)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:80)
    at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
    at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
    at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:51)
    at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:169)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
    at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
    at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
    at org.gradle.launcher.Main.doAction(Main.java:33)
    at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
    at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Caused by: org.gradle.api.GradleException: There were failing tests. See the report at: file:///home/ec2-user/repositories/MyProject/robolectric-tests/build/reports/tests/index.html
    at org.gradle.api.tasks.testing.Test.handleTestFailures(Test.java:1118)
    at org.gradle.api.tasks.testing.Test.executeTests(Test.java:549)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:218)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:211)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:200)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:585)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:568)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
    ... 44 more


BUILD FAILED
like image 290
Lau Llobet Avatar asked Feb 17 '15 17:02

Lau Llobet


People also ask

How to install Gradle on Ubuntu?

Install Gradle on Ubuntu/Debian 1 Install Java on Ubuntu. Installing Gradle on Linux requires the Java 8 or higher version. ... 2 Download Gradle on Ubuntu. Gradle is available as a binary file for Linux systems. ... 3 Configure and Set Up Gradle on Ubuntu. ... 4 Verify Gradle on Ubuntu Linux. ...

What is Gradle build tool?

Gradle is one of the best open-source automation build tools that are available for Linux systems. The Gradle build tool is used for faster, efficient, and organized software development and production.

How to use Gradle with Jenkins on Ubuntu?

Since Gradle is used for automation, you can use Gradle with Jenkins if you have an existing Jenkins server on your system. From here, you can get the Gradle -Jenkins plugin for your Ubuntu system. In the entire post, I’ve demonstrated the method of installing the Gradle tool on a Ubuntu machine.


1 Answers

I also ran into this issue on Linux but not OSX. I found a work-around by adding

org.apache.maven:maven-ant-tasks:2.1.3

to my 'testCompile' dependencies.

dependencies {
  repositories {
    mavenCentral()
  }
  testCompile 'junit:junit:4.12'
  testCompile 'org.apache.maven:maven-ant-tasks:2.1.3'
  testCompile 'org.robolectric:robolectric:2.4'
  testCompile 'org.mockito:mockito-all:1.9.5'
}

I don't know why maven-ant-tasks isn't getting fetched on linux. It appears to be a valid dependency of robolectric.

like image 75
marketer Avatar answered Oct 07 '22 12:10

marketer