Giter VIP home page Giter VIP logo

robolectric-gradle-plugin's Introduction

Build Status GitHub release

Robolectric is the industry-standard unit testing framework for Android. With Robolectric, your tests run in a simulated Android environment inside a JVM, without the overhead and flakiness of an emulator. Robolectric tests routinely run 10x faster than those on cold-started emulators.

Robolectric supports running unit tests for 14 different versions of Android, ranging from Lollipop (API level 21) to U (API level 34).

Usage

Here's an example of a simple test written using Robolectric:

@RunWith(AndroidJUnit4.class)
public class MyActivityTest {

  @Test
  public void clickingButton_shouldChangeResultsViewText() {
    Activity activity = Robolectric.setupActivity(MyActivity.class);

    Button button = (Button) activity.findViewById(R.id.press_me_button);
    TextView results = (TextView) activity.findViewById(R.id.results_text_view);

    button.performClick();
    assertThat(results.getText().toString(), equalTo("Testing Android Rocks!"));
  }
}

For more information about how to install and use Robolectric on your project, extend its functionality, and join the community of contributors, please visit http://robolectric.org.

Install

Starting a New Project

If you'd like to start a new project with Robolectric tests you can refer to deckard (for either maven or gradle) as a guide to setting up both Android and Robolectric on your machine.

build.gradle:

testImplementation "junit:junit:4.13.2"
testImplementation "org.robolectric:robolectric:4.13"

Building And Contributing

Robolectric is built using Gradle. Both IntelliJ and Android Studio can import the top-level build.gradle file and will automatically generate their project files from it.

To get a high-level overview of Robolectric's architecture, check out ARCHITECTURE.md.

Prerequisites

See Building Robolectric for more details about setting up a build environment for Robolectric.

Building

Robolectric supports running tests against multiple Android API levels. The work it must do to support each API level is slightly different, so its shadows are built separately for each. To build shadows for every API version, run:

./gradlew clean assemble testClasses --parallel

Testing

Run tests for all API levels:

The fully tests could consume more than 16G memory(total of physical and virtual memory).

./gradlew test --parallel

Run tests for part of supported API levels, e.g. run tests for API level 26, 27, 28:

./gradlew test --parallel "-Drobolectric.enabledSdks=26,27,28"

Run compatibility test suites on opening Emulator:

./gradlew connectedCheck

Using Snapshots

If you would like to live on the bleeding edge, you can try running against a snapshot build. Keep in mind that snapshots represent the most recent changes on master and may contain bugs.

build.gradle:

repositories {
    maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
dependencies {
    testImplementation "org.robolectric:robolectric:4.14-SNAPSHOT"
}

robolectric-gradle-plugin's People

Contributors

avh4 avatar bbergler avatar blundell avatar chrisjenx avatar christiankatzmann avatar cyrret avatar dodgex avatar erd avatar frankdu avatar friederbluemle avatar frownlee avatar gdaniels avatar jakewharton avatar jaredsburrows avatar mag avatar marcinkwiatkowski avatar matthewmichihara avatar roman-mazur avatar ry4n1m3 avatar scompt avatar skyisle avatar thorikawa avatar ytolsk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

robolectric-gradle-plugin's Issues

Can't work with AS 0.6.1 (Gradle 0.11)

Cannot run gradle test, it fails with error:

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lorg/codehaus/classworlds/BytesURLConnection;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594)

I'm using classpath 'org.robolectric:robolectric-gradle-plugin:0.11.+' and dependencies:

androidTestCompile 'junit:junit:4.11'
androidTestCompile 'org.robolectric:robolectric:2.3+'
androidTestCompile 'com.squareup:fest-android:1.0.+'

When I comment out robolectric - build succeeds and starts android emulator.

Unsupported major.minor version 52.0

When try build project (./gradlew cl asDebug) I receive message
Cause: org/robolectric/gradle/RobolectricPlugin : Unsupported major.minor version 52.0.

Version of robolectric plugin 0.13.1. On version 0.13.0 I have no problems.

RFC: Naming suggestion

Because android gradle plugin introduced androidTest that is so similar with this plugin, how about making below naming changes?

  1. Change plugin name from android-test to android-robolectric
    Before: apply plugin: 'android-test'
    After: apply plugin: 'android-robolectric'
  2. Change the configuration name from androidTest to robolectric

What do you think?

MenuItemCompat.getActionView(itemId) returns null

We know that Robolectric just keeps silent by giving null, 0 values. And it seems that it doesn't handle method call MenuItemCompat.getActionView() well. See the following snippet which is failed to execute with Robolectric.

SearchView searchView = (SearchView) MenuItemCompat.getActionView(
    menu.findItem(R.id.action_search));

On this snippet, Robolectric is failed to retrieve SearchView object, making the searchView variable to be null. Perhaps Robolectric misses some shadow implementations here?

After debugging, I found that prior to calling android.support.v7.internal.view.menu.MenuItemImpl.getActionView(), the MenuItemImpl instance already doesn't have mActionView (mActionView = null), where in non-compat one does have.

Deeper debugging, I found that ShadowMenuInflater.addActionViewToItem only retrieves actionViewClassName from namespace named android (http://schemas.android.com/apk/res/android). While in AppCompat, the namespace is app (http://schemas.android.com/apk/res-auto)

Look at this:

private void addActionViewToItem(MenuItem item, RoboAttributeSet attributes) {
    String actionViewClassName = attributes.getAttributeValue(ANDROID_NS, "actionViewClass");
    if (actionViewClassName != null) {
      try {
        View actionView = (View) type(actionViewClassName).load().getConstructor(Context.class).newInstance(context);
        item.setActionView(actionView);
      } catch (Exception e) {
        throw new RuntimeException("Action View class not found!", e);
      }
    }
 }

I think it'd be better if Robolectric gives me exceptions to let me know which shadows to implement.

Robolectric + JUnit test case written in Scala doesn't work

Hey, I use your plugin with p.leafytree.gradle:gradle-android-scala-plugin. It looks like gradle clean test doesn't try to compile nor use test code I write in Scala and put in src/androidTest/scala.

I've managed to run JUnit + Robolectric tests written in Java, simple, but my goal is to write them in Scala. At least pure JUnit + Robolectric but in Scala. In better world I'd use ScalaTest Matchers and in perfect world I'd use ScalaTest instead of JUnit but lets start simple.

I want to run this test case with all my Java JUnit test cases:

@RunWith(classOf[RobolectricTestRunner])
class PureJUnitScalaTest {
  @Test def sampleTest(): Unit = {
    assertThat(10, is(10))
  }
}

I attach my test project with whole gradle configuration and source code.

I'm not exactly sure if this is problem with robolectric-gradle-plugin but I hope you can help me.

jvmArgs not being passed to GradleWorkerMain

None of the jvmArgs (either task or project specific) are passed to the GradleWorkerMain that is launched to run the individual tests. I was able to get to this to pass correctly by adding this line of code:

testRunTask.setJvmArgs(extension.jvmArgs)

to line 166 of RobolectricPlugin.groovy. Is there a way that we can have this functionality added to the release?

Thanks.

Can not have more than 1 content provider testcase

Hey guys,

Thanks for the amazing work on this useful library.

Currently, I'm experiencing a bug with version 0.10.+. I can test CRUD for Content Provider using ShadowContentResolver (as an example here http://stackoverflow.com/questions/18022923/robolectric-contentprovider-testing).

But if I add more test cases, only the 1st work, the rest will be failed. So I did a workaround by having only 1 fat test case which covers all the cases of CRUD for my ContentProvider. W00t, everything works fine.

Later on, I had to implement another ContentProvider, so I did the same: having another Test class whose 1 fat test case. This test case simply doesn't work, it always failed. After hours of debugging, I found out that the temporary database created by Robolectric will be closed and deleted after the first test case run.

Anyone else got the same issue while testing ContentProvider with Robolectric?

Plugin v0.13.1 with sdk-manager-plugin fails the build

Just switched to plugin v0.13.1 (because of jvmArgs), of course I tried to run clean build on my machine and everything was okay, then I pushed changes to VCS and CI server started the build and result was: BUILD FAILURE

I checked it several times, just switching to v0.13.1 instead of v0.13.0 (without any other changes in project) fails the build.

As I understand, robolectric plugin v0.13.1 changes some build tools settings, because when I build project with robolectric plugin v0.13.0 I don't see logs [Step 1/1] Build tools null missing. Downloading...

I don't know where the problem lives: robolectric-plugin or sdk-manager-plugin, but I faced it after switching to robolectric-plugin v0.13.1 so I created issue here.

May be @JakeWharton know something about this issue?

Here is the build log:

[10:42:04][Step 1/1] Build tools null missing. Downloading... [10:42:12][Step 1/1] Failed to notify ProjectEvaluationListener.afterEvaluate(), but primary configuration failure takes precedence. [10:42:12][Step 1/1] java.lang.NullPointerException: Cannot invoke method startsWith() on null object [10:42:12][Step 1/1] at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:88) [10:42:12][Step 1/1] at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45) [10:42:12][Step 1/1] at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) [10:42:12][Step 1/1] at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:32) [10:42:12][Step 1/1] at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) [10:42:12][Step 1/1] at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) [10:42:12][Step 1/1] at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) [10:42:12][Step 1/1] at com.jakewharton.sdkmanager.internal.PackageResolver.resolveCompileVersion(PackageResolver.groovy:101) [10:42:12][Step 1/1] at com.jakewharton.sdkmanager.internal.PackageResolver.resolve(PackageResolver.groovy:60) [10:42:12][Step 1/1] at com.jakewharton.sdkmanager.internal.PackageResolver$resolve$0.call(Unknown Source) [10:42:12][Step 1/1] at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) [10:42:12][Step 1/1] at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) [10:42:12][Step 1/1] at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112) [10:42:12][Step 1/1] at com.jakewharton.sdkmanager.internal.PackageResolver.resolve(PackageResolver.groovy:20) [10:42:12][Step 1/1] at com.jakewharton.sdkmanager.internal.PackageResolver$resolve.call(Unknown Source) [10:42:12][Step 1/1] at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) [10:42:12][Step 1/1] at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) [10:42:12][Step 1/1] at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120) [10:42:12][Step 1/1] at com.jakewharton.sdkmanager.SdkManagerPlugin$_apply_closure2_closure3.doCall(SdkManagerPlugin.groovy:38) [10:42:12][Step 1/1] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [10:42:12][Step 1/1] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [10:42:12][Step 1/1] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [10:42:12][Step 1/1] at java.lang.reflect.Method.invoke(Method.java:606) [10:42:12][Step 1/1] at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) [10:42:12][Step 1/1] at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324) [10:42:12][Step 1/1] at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:278) [10:42:12][Step 1/1] at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016) [10:42:12][Step 1/1] at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66) [10:42:12][Step 1/1] at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49) [10:42:12][Step 1/1] at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133) [10:42:12][Step 1/1] at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141) [10:42:12][Step 1/1] at com.jakewharton.sdkmanager.SdkManagerPlugin$_apply_closure2_closure3.doCall(SdkManagerPlugin.groovy) [10:42:12][Step 1/1] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [10:42:12][Step 1/1] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [10:42:12][Step 1/1] [10:42:12][Step 1/1] BUILD FAILED [10:42:12][Step 1/1] [10:42:12][Step 1/1] Total time: 13.58 secs [10:42:12][Step 1/1] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [10:42:12][Step 1/1] at java.lang.reflect.Method.invoke(Method.java:606) [10:42:12][Step 1/1] at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) [10:42:12][Step 1/1] at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324) [10:42:12][Step 1/1] at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:278) [10:42:12][Step 1/1] at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016) [10:42:12][Step 1/1] at groovy.lang.Closure.call(Closure.java:423) [10:42:12][Step 1/1] at groovy.lang.Closure.call(Closure.java:417) [10:42:12][Step 1/1] at groovy.lang.Closure.run(Closure.java:504) [10:42:12][Step 1/1] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [10:42:12][Step 1/1] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [10:42:12][Step 1/1] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [10:42:12][Step 1/1] at java.lang.reflect.Method.invoke(Method.java:606) [10:42:12][Step 1/1] at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) [10:42:12][Step 1/1] at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324) [10:42:12][Step 1/1] at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:278) [10:42:12][Step 1/1] at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016) [10:42:12][Step 1/1] at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:39) [10:42:12][Step 1/1] at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) [10:42:12][Step 1/1] at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:54) [10:42:12][Step 1/1] at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112) [10:42:12][Step 1/1] at com.jakewharton.sdkmanager.SdkManagerPlugin.time(SdkManagerPlugin.groovy:45) [10:42:12][Step 1/1] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [10:42:12][Step 1/1] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [10:42:12][Step 1/1] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [10:42:12][Step 1/1] at java.lang.reflect.Method.invoke(Method.java:606) [10:42:12][Step 1/1] at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) [10:42:12][Step 1/1] at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324) [10:42:12][Step 1/1] at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:368) [10:42:12][Step 1/1] at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016) [10:42:12][Step 1/1] at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66) [10:42:12][Step 1/1] at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49) [10:42:12][Step 1/1] at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133) [10:42:12][Step 1/1] at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:145) [10:42:12][Step 1/1] at com.jakewharton.sdkmanager.SdkManagerPlugin$_apply_closure2.doCall(SdkManagerPlugin.groovy:37) [10:42:12][Step 1/1] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [10:42:12][Step 1/1] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [10:42:12][Step 1/1] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [10:42:12][Step 1/1] at java.lang.reflect.Method.invoke(Method.java:606) [10:42:12][Step 1/1] at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) [10:42:12][Step 1/1] at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324) [10:42:12][Step 1/1] at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:278) [10:42:12][Step 1/1] at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016) [10:42:12][Step 1/1] at groovy.lang.Closure.call(Closure.java:423) [10:42:12][Step 1/1] at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:40) [10:42:12][Step 1/1] at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:25) [10:42:12][Step 1/1] at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:83) [10:42:12][Step 1/1] at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:31) [10:42:12][Step 1/1] at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93) [10:42:12][Step 1/1] at com.sun.proxy.$Proxy13.afterEvaluate(Unknown Source) [10:42:12][Step 1/1] at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:67) [10:42:12][Step 1/1] at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:61) [10:42:12][Step 1/1] at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:521) [10:42:12][Step 1/1] at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:82) [10:42:12][Step 1/1] at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:31) [10:42:12][Step 1/1] at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:129) [10:42:12][Step 1/1] at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106) [10:42:12][Step 1/1] at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86) [10:42:12][Step 1/1] at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:80) [10:42:12][Step 1/1] at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33) [10:42:12][Step 1/1] at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24) [10:42:12][Step 1/1] at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36) [10:42:12][Step 1/1] at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:47) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:35) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:24) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.exec.StartStopIfBuildAndStop.execute(StartStopIfBuildAndStop.java:33) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.exec.ReturnResult.execute(ReturnResult.java:34) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:71) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:69) [10:42:12][Step 1/1] at org.gradle.util.Swapper.swap(Swapper.java:38) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:69) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:70) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:45) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.DaemonStateCoordinator.runCommand(DaemonStateCoordinator.java:258) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy.doBuild(StartBuildOrRespondWithBusy.java:49) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.exec.HandleCancel.execute(HandleCancel.java:36) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.exec.HandleStop.execute(HandleStop.java:30) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.exec.DaemonHygieneAction.execute(DaemonHygieneAction.java:39) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.exec.CatchAndForwardDaemonFailure.execute(CatchAndForwardDaemonFailure.java:32) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.exec.DefaultDaemonCommandExecuter.executeCommand(DefaultDaemonCommandExecuter.java:52) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.handleCommand(DefaultIncomingConnectionHandler.java:154) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.receiveAndHandleCommand(DefaultIncomingConnectionHandler.java:128) [10:42:12][Step 1/1] at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.run(DefaultIncomingConnectionHandler.java:116) [10:42:12][Step 1/1] at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64) [10:42:12][Step 1/1] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [10:42:12][Step 1/1] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [10:42:12][Step 1/1] at java.lang.Thread.run(Thread.java:745) [10:42:12][Step 1/1] [10:42:12][Step 1/1] Process exited with code 1

No test reports XML files when using version 0.11.+

I just upgraded robolectric-gradle-plugin to 0.11.+. But I don't see any test report XML files after running the tests. I only see the binary files at test-results/binary/testDebug.

Is there any configuration so I can enable XML output in test reports?

No support for Gradle 0.12.+

Android Studio 0.8.x uses Gradle 0.12.x as a build tool, but there's no supported robolectric-gradle-plugin available.

NullPointerException when loading AndroidManifest.xml with google_play_services_version meta-data entry

Myself and @ericTsiliacos are running into an issue with resource loading and Robolectric with Gradle. On the command line, the AndroidManifest.xml is discovered automatically, but the resources directory is not. When running in Intellij, neither are properly discovered. It appears to be related to robolectric/robolectric#1025 on Robolectric.

We see the issue with Robolectric 2.3, 2.4-SNAPSHOT, and the Android gradle plugin 0.11.+ and 0.12.+.

We found that explicitly setting the locations allowed us to successfully run tests in both environments:
@Config(manifest = "build/intermediates/manifests/debug/AndroidManifest.xml", resourceDir = "../../../../build/intermediates/res/debug", emulateSdk = 18)

We were pointed to #52, and found that specifying the applicationId allowed tests to run on the command line with simply @Config(emulateSdk = 18), however the full config was still needed to run tests inside of Intellij.

It seems like it should be unnecessary to specify these paths, given that our project is using the standard android gradle directory structure. Is there some other preferred way of configuring this, or is possibly a bug in test environment generated by the robolectric-gradle-plugin?

Code coverage?

Is it possible to enable code coverage, e.g. jacoco, and - that would be awesome - merge the jacoco results of robolectric with those from the instrumentation tests?

JDK8

Yet to confirm but googling seems to suggest that useding JDK8 breaks ASM.

Not sure if you are able to allow the plugin to pull in the source compatibility setttings in compileOptions as on JDK8 you get this exception:

java.lang.IllegalArgumentException
    at org.objectweb.asm.ClassReader.<init>(Unknown Source)
    at org.objectweb.asm.ClassReader.<init>(Unknown Source)
    at org.robolectric.bytecode.AsmInstrumentingClassLoader.findClass(AsmInstrumentingClassLoader.java:140)
    at org.robolectric.bytecode.AsmInstrumentingClassLoader.loadClass(AsmInstrumentingClassLoader.java:98)
    at org.robolectric.SdkEnvironment.bootstrappedClass(SdkEnvironment.java:45)
    at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:205)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:177)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    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:50)
    at sun.reflect.GeneratedMethodAccessor11.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    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.GeneratedMethodAccessor10.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    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:355)
    at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:744)

My temporary fix for this is too include the following before robolectric in my build.gradle:

// We use ASM 5 as it works with JDK8
    androidTestCompile 'org.ow2.asm:asm:5.+',
            'org.ow2.asm:asm-commons:5.+',
            'org.ow2.asm:asm-util:5.+',
            'org.ow2.asm:asm-analysis:5.+'

Issue when using com.android.support:appcompat-v7:21.+

If I have this appcompt-v7 version defined for compile, I get an issue with robolectric:

compile 'com.android.support:appcompat-v7:21.+'

  • What went wrong:
    A problem occurred configuring project ':app'.

    A problem occurred configuring project ':core'.
    Module version org.robolectric:robolectric:2.3 depends on libraries but is not a library itself

Test not run in not default test sources dir

I put my test classes in "test" directory of module, and set in build.gradle that directory as android test root. When I try run tests, tests not execute. With standard directory hierarchy (src/androidTest) all tests work.

Unable to log to gradle console

I've been trying to log traces of the test in gradle console but it's been mission impossible, can you point me out if the plugin redirect the Robolectrict output to gradle or if is out of the scope of the plugin?

Things I;ve try

ShadowLog

ShadowLog.stream = System.out;
System.out.println("someother log");
ShadowLog.i("LogTest", "log message");

Robolectric.logging

robolectric {
System.properties['robolectric.logging'] = 'stdout'
}

And even gradlew -i but still unable to print,

version 0.9.3 problem

In order to use android gradle plugin 0.9+, I update to the 0.9.3 gradle android test plugin. The plugin reports this error:

Configuration with name "instrumentTestCompile" not found

I did not find I use instrumentTestCompile configuration in my gradle file. And after read the gradle-android-test-plugin code, it has use androidTestCompile configuration according to the android gradle plugin of v0.9.0, so, any ideas about this error?

Example project: deckard-gradle roboelectric tests error

I am using InteliJ 13.1.2 Build #IC-135.690 and I have followed all the prerequisites steps for intelij13 but I am getting the following error when trying to run Roboelectric test either from the command line or from the IDE.

WARNING: no system properties value for ro.build.date.utc
DEBUG: Loading resources for android from jar:/Users/cpeppa01/.m2/repository/org/robolectric/android-all/4.1.2_r1-robolectric-0/android-all-4.1.2_r1-robolectric-0.jar!/res...

android.content.res.Resources$NotFoundException: unknown resource 2130837504
at org.robolectric.shadows.ShadowAssetManager.getAndResolve(ShadowAssetManager.java:272)
at org.robolectric.shadows.ShadowAssetManager.getResourceValue(ShadowAssetManager.java:85)
at android.content.res.AssetManager.getResourceValue(AssetManager.java)
at android.content.res.Resources.getValue(Resources.java:1009)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2098)
at android.content.res.Resources.getLayout(Resources.java:852)
at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
at android.app.Activity.setContentView(Activity.java:1867)
at com.example.robolectric.DeckardActivity.onCreate(DeckardActivity.java:12)
at android.app.Activity.performCreate(Activity.java:5008)
at org.fest.reflect.method.Invoker.invoke(Invoker.java:112)
at org.robolectric.util.ActivityController$1.run(ActivityController.java:147)
at org.robolectric.shadows.ShadowLooper.runPaused(ShadowLooper.java:265)
at org.robolectric.util.ActivityController.create(ActivityController.java:144)
at org.robolectric.util.ActivityController.create(ActivityController.java:154)
at com.example.activity.DeckardActivityRobolectricTest.testSomething(DeckardActivityRobolectricTest.java:20)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:250)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:177)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)

Process finished with exit code 255

Just to note that the app is not modified and only espresso tests are running fine

Leveraging androidTestCompile as the configuration results in unnecessary jars on the classpath

I was using the previous iteration of this plugin (on Gradle Android Plugin 0.9.x) and have attempted to upgrade to leverage the latest Gradle plugin.

In the previous iteration of the plugin, there was a "testCompile" configuration which kept the classpath separate from the instrumentation test classpath. The new version does not appear to keep that separation.

That appears to cause some problems. For example, for "instrumentation tests" (androidTest) we need to define "dexmaker-mockito" as a dependency in order to have proper Mockito support in android tests. However, for simple unit tests this is not needed and actually causes problems (null pointer exceptions, forcing the addition of the dexcache system property, etc.) when included, meaning one can either have unit tests or android tests, but not both (at least as far as I can tell).

Is there (a) a work-around I am missing or (b) a plan to separate these configurations again?

Failures should include the message from the exception in build log

When a test fails it just prints the type of exception in the gradle build log as in:

DummyTest > testSomething FAILED   
    org.junit.ComparisonFailure at DummyTest.java:29

And you end up having to go look at the report file to see why it is failed. In doing TDD you need to be able to quickly verify that it failed for the reason you thought it should fail.

It should (or at least have the option to) show the message from the exception in the build log. Seeing something like this is much more helpful:

DummyTest > testSomething FAILED   
    org.junit.ComparisonFailure at DummyTest.java:29
        expected:<[7]> but was:<[5]>

com.android.tools.build:gradle:0.11 broke gradle-android-test-plugin

18:31:02.045 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':form_builder'.
18:31:02.045 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:79)
18:31:02.045 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:74)
18:31:02.045 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:61)
18:31:02.046 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:493)
18:31:02.046 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.project.AbstractProject.evaluationDependsOn(AbstractProject.java:597)
18:31:02.046 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.project.AbstractProject.evaluationDependsOn(AbstractProject.java:589)
18:31:02.046 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.Project$evaluationDependsOn.call(Unknown Source)
18:31:02.046 [ERROR] [org.gradle.BuildExceptionReporter]    at com.android.build.gradle.BasePlugin$_ensureConfigured_closure161.doCall(BasePlugin.groovy:2440)
18:31:02.046 [ERROR] [org.gradle.BuildExceptionReporter]    at com.android.build.gradle.BasePlugin.ensureConfigured(BasePlugin.groovy:2439)
18:31:02.046 [ERROR] [org.gradle.BuildExceptionReporter]    at com.android.build.gradle.BasePlugin.resolveDependencyForConfig(BasePlugin.groovy:2357)
18:31:02.046 [ERROR] [org.gradle.BuildExceptionReporter]    at com.android.build.gradle.BasePlugin.this$2$resolveDependencyForConfig(BasePlugin.groovy)
18:31:02.047 [ERROR] [org.gradle.BuildExceptionReporter]    at com.android.build.gradle.BasePlugin$this$2$resolveDependencyForConfig.callCurrent(Unknown Source)
18:31:02.047 [ERROR] [org.gradle.BuildExceptionReporter]    at com.android.build.gradle.BasePlugin.resolveDependencies(BasePlugin.groovy:2276)
18:31:02.047 [ERROR] [org.gradle.BuildExceptionReporter]    at com.android.build.gradle.internal.VariantManager.createTasksForDefaultBuild(VariantManager.java:304)
18:31:02.047 [ERROR] [org.gradle.BuildExceptionReporter]    at com.android.build.gradle.internal.VariantManager.createAndroidTasks(VariantManager.java:167)
18:31:02.047 [ERROR] [org.gradle.BuildExceptionReporter]    at com.android.build.gradle.internal.VariantManager$createAndroidTasks.call(Unknown Source)
18:31:02.047 [ERROR] [org.gradle.BuildExceptionReporter]    at com.android.build.gradle.BasePlugin.createAndroidTasks(BasePlugin.groovy:422)
18:31:02.047 [ERROR] [org.gradle.BuildExceptionReporter]    at com.android.build.gradle.BasePlugin$_apply_closure7.doCall(BasePlugin.groovy:333)
18:31:02.047 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:40)
18:31:02.048 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:25)
18:31:02.048 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:83)
18:31:02.048 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:31)
18:31:02.048 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
18:31:02.048 [ERROR] [org.gradle.BuildExceptionReporter]    at com.sun.proxy.$Proxy13.afterEvaluate(Unknown Source)
18:31:02.048 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:67)
18:31:02.048 [ERROR] [org.gradle.BuildExceptionReporter]    ... 29 more
18:31:02.048 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: org.codehaus.groovy.runtime.InvokerInvocationException: java.lang.NoClassDefFoundError: com.android.builder.BuilderConstants
18:31:02.049 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:40)
18:31:02.049 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:25)
18:31:02.049 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:83)
18:31:02.049 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:31)
18:31:02.049 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
18:31:02.049 [ERROR] [org.gradle.BuildExceptionReporter]    at com.sun.proxy.$Proxy13.afterEvaluate(Unknown Source)
18:31:02.049 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:67)
18:31:02.049 [ERROR] [org.gradle.BuildExceptionReporter]    ... 52 more
18:31:02.050 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.lang.NoClassDefFoundError: com.android.builder.BuilderConstants
18:31:02.050 [ERROR] [org.gradle.BuildExceptionReporter]    at org.robolectric.gradle.AndroidTestPlugin$_apply_closure1.class$(AndroidTestPlugin.groovy)
18:31:02.050 [ERROR] [org.gradle.BuildExceptionReporter]    at org.robolectric.gradle.AndroidTestPlugin$_apply_closure1.$get$$class$com$android$builder$BuilderConstants(AndroidTestPlugin.groovy)
18:31:02.050 [ERROR] [org.gradle.BuildExceptionReporter]    at org.robolectric.gradle.AndroidTestPlugin$_apply_closure1.doCall(AndroidTestPlugin.groovy:44)
18:31:02.050 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:58)
18:31:02.050 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.listener.ActionBroadcast.execute(ActionBroadcast.java:39)
18:31:02.050 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.DefaultDomainObjectCollection.doAdd(DefaultDomainObjectCollection.java:164)
18:31:02.050 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.DefaultDomainObjectCollection.add(DefaultDomainObjectCollection.java:159)
18:31:02.051 [ERROR] [org.gradle.BuildExceptionReporter]    at com.android.build.gradle.LibraryExtension.addVariant(LibraryExtension.groovy:49)
18:31:02.051 [ERROR] [org.gradle.BuildExceptionReporter]    at com.android.build.gradle.internal.VariantManager.createVariantApiObjects(VariantManager.java:597)
18:31:02.051 [ERROR] [org.gradle.BuildExceptionReporter]    at com.android.build.gradle.internal.VariantManager.createApiObjects(VariantManager.java:569)
18:31:02.051 [ERROR] [org.gradle.BuildExceptionReporter]    at com.android.build.gradle.internal.VariantManager.createAndroidTasks(VariantManager.java:216)
18:31:02.051 [ERROR] [org.gradle.BuildExceptionReporter]    at com.android.build.gradle.internal.VariantManager$createAndroidTasks.call(Unknown Source)
18:31:02.051 [ERROR] [org.gradle.BuildExceptionReporter]    at com.android.build.gradle.BasePlugin.createAndroidTasks(BasePlugin.groovy:422)
18:31:02.051 [ERROR] [org.gradle.BuildExceptionReporter]    at com.android.build.gradle.BasePlugin$_apply_closure7.doCall(BasePlugin.groovy:333)
18:31:02.051 [ERROR] [org.gradle.BuildExceptionReporter]    ... 59 more

Executing tests fails randomly

Tried to execute my robolectric tests throught gradle, but on a randomly test execution is stopped and gradle fails. Any idea whats causing this and how to solve this?

Stacktrace

Cannot invoke method getTargetInfo() on null object

This method doesn't exist or isn't implemented by dexguard. Or this method is invoked incorrectly.

* What went wrong:
Execution failed for task ':justyoyo:compileTestJustyoyoDevDebugJava'.
> Cannot invoke method getTargetInfo() on null object

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

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':justyoyo:compileTestJustyoyoDevDebugJava'.
    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:305)
    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.ParallelTaskPlanExecutor.process(ParallelTaskPlanExecutor.java:51)
    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.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:47)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:35)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:24)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.StartStopIfBuildAndStop.execute(StartStopIfBuildAndStop.java:33)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.ReturnResult.execute(ReturnResult.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:71)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:69)
    at org.gradle.util.Swapper.swap(Swapper.java:38)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:69)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:70)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:45)
    at org.gradle.launcher.daemon.server.DaemonStateCoordinator.runCommand(DaemonStateCoordinator.java:258)
    at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy.doBuild(StartBuildOrRespondWithBusy.java:49)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.HandleCancel.execute(HandleCancel.java:36)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.HandleStop.execute(HandleStop.java:30)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.DaemonHygieneAction.execute(DaemonHygieneAction.java:39)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.CatchAndForwardDaemonFailure.execute(CatchAndForwardDaemonFailure.java:32)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.DefaultDaemonCommandExecuter.executeCommand(DefaultDaemonCommandExecuter.java:52)
    at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.handleCommand(DefaultIncomingConnectionHandler.java:154)
    at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.receiveAndHandleCommand(DefaultIncomingConnectionHandler.java:128)
    at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.run(DefaultIncomingConnectionHandler.java:116)
    at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
Caused by: java.lang.NullPointerException: Cannot invoke method getTargetInfo() on null object
    at com.android.builder.core.AndroidBuilder$getTargetInfo$1.call(Unknown Source)
    at com.android.build.gradle.BasePlugin.ensureTargetSetup(BasePlugin.groovy:538)
    at com.android.build.gradle.BasePlugin.getBootClasspath(BasePlugin.groovy:531)
    at com.android.build.gradle.BasePlugin$getBootClasspath$17.call(Unknown Source)
    at org.robolectric.gradle.RobolectricPlugin$_apply_closure1_closure3.doCall(RobolectricPlugin.groovy:104)
    at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:548)
    at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:529)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
    ... 69 more

Could not find method afterTest() on project ':app'

Given this project descriptor:

buildscript {
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:0.12.2'
    classpath 'org.robolectric:robolectric-gradle-plugin:0.12.+'
  }
}
apply plugin: 'com.android.application'
apply plugin: 'robolectric'

android {
  compileSdkVersion 19
  buildToolsVersion "19.1.0"

  defaultConfig {
    applicationId "com.foo.bar"
    minSdkVersion 16
    targetSdkVersion 19
    versionCode 1
    versionName "1.0"
  }
  buildTypes {
    release {
      runProguard false
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
  }

  packagingOptions {
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/NOTICE'
  }
}

dependencies {
  compile project(':eventbus')
  compile project(':network')

  androidTestCompile 'org.hamcrest:hamcrest-integration:1.1'
  androidTestCompile 'org.hamcrest:hamcrest-core:1.1'
  androidTestCompile 'org.hamcrest:hamcrest-library:1.1'

  androidTestCompile('junit:junit:4.11') {
    exclude module: 'hamcrest-core'
  }
  androidTestCompile('org.robolectric:robolectric:2.3') {
    exclude module: 'classworlds'
    exclude module: 'commons-logging'
    exclude module: 'httpclient'
    exclude module: 'maven-artifact'
    exclude module: 'maven-artifact-manager'
    exclude module: 'maven-error-diagnostics'
    exclude module: 'maven-model'
    exclude module: 'maven-project'
    exclude module: 'maven-settings'
    exclude module: 'plexus-container-default'
    exclude module: 'plexus-interpolation'
    exclude module: 'plexus-utils'
    exclude module: 'wagon-file'
    exclude module: 'wagon-http-lightweight'
    exclude module: 'wagon-provider-api'
  }
}

robolectric {
  include '**/*Test.class'
  maxHeapSize = '2048m'
  ignoreFailures true

  afterTest { descriptor, result ->
    println "Executing test for {$descriptor.name} with result: ${result.resultType}"
  }
}

Y run ./gradlew test --stacktrace and get this output:

$ ./gradlew clean test --stacktrace

FAILURE: Build failed with an exception.

* Where:
Build file '/home/mdumrauf/workspace/java/android/Foo/app/build.gradle' line: 63

* What went wrong:
A problem occurred evaluating project ':app'.
> Could not find method afterTest() for arguments [build_8qimn5atgapaohm4ce1rgg3a0$_run_closure3_closure10@7ac260c5] on project ':app'.

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

* Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating project ':app'.
    at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:54)
    at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:152)
    at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:40)
    at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:26)
    at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
    at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:55)
    at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:493)
    at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:80)
    at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:31)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:142)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:64)
    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:35)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
    at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)
    at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:201)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:174)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:170)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139)
    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:46)
    at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
    at org.gradle.launcher.Main.main(Main.java:37)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32)
    at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
    at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:33)
    at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:130)
    at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
Caused by: org.gradle.api.internal.MissingMethodException: Could not find method afterTest() for arguments [build_8qimn5atgapaohm4ce1rgg3a0$_run_closure3_closure10@7ac260c5] on project ':app'.
    at org.gradle.api.internal.AbstractDynamicObject.methodMissingException(AbstractDynamicObject.java:68)
    at org.gradle.api.internal.AbstractDynamicObject.invokeMethod(AbstractDynamicObject.java:56)
    at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:172)
    at org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.java:79)
    at build_8qimn5atgapaohm4ce1rgg3a0$_run_closure3.doCall(/home/matias/workspace/java/android/ControlRemote/app/build.gradle:63)
    at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:58)
    at org.gradle.api.internal.plugins.ExtensionsStorage$ExtensionHolder.configure(ExtensionsStorage.java:145)
    at org.gradle.api.internal.plugins.ExtensionsStorage.configureExtension(ExtensionsStorage.java:69)
    at org.gradle.api.internal.plugins.DefaultConvention$ExtensionsDynamicObject.invokeMethod(DefaultConvention.java:213)
    at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:147)
    at org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.java:79)
    at build_8qimn5atgapaohm4ce1rgg3a0.run(/home/matias/workspace/java/android/ControlRemote/app/build.gradle:58)
    at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52)
    ... 33 more


BUILD FAILED

Total time: 3.099 secs

option to provide a packageName to use

related to robolectric/robolectric#1150

currently robolectric for gradle does not work as-is when using applicationIdSuffix in a buildType or Flavour. the problem is that robolectric then tries to find the resources in the package applicationId.applicationIdSuffix (as found in AndroidManifest.xml) but the resoruces actually are available under applicationId

e.g
applicationId = app.pack.age
applicationIdSuffix = .dev
resoruces found via = app.pack.age
resources searched = app.pack.age.dev

in the above mentioned issue for robolectric we found a workaround for this, but imho it is an ugly solution.

tasks.withType(Test).whenTaskAdded {
    it.systemProperty 'android.package', android.defaultConfig.applicationId // your package name
}

i think this plugin deserves an option to pass the package name like:

robolectric {
    packageName android.defaultConfig.applicationId 
}

or even better, set this value per default as the resources are always available via android.defaultConfig.applicationId even for build Flavours with a totaly diffrent applicationId set.

Non-reproduceable build fail with gradle-android-test-plugin

I'm using this plugin in one of my projects. On 3 of 4 machines, ./gradlew --daemon test is successful. One the other it fails (stack trace below).

The build.gradle is located here, the .travis.yml is here here. All machines are running Linux with the same java version (1.7.0_55) although in different "flavors" [0].

Is this an error in my build.gradle, a local misconfiguration of my operating system or a bug in gradle/gradle-android-test-plugin?

java.lang.RuntimeException: java.lang.RuntimeException: Stub!
    at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:240)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:177)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    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:50)
    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:103)
    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:355)
    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:744)
Caused by: java.lang.RuntimeException: Stub!
    at android.net.Uri.parse(Uri.java:53)
    at org.robolectric.shadows.ShadowMediaStore.reset(ShadowMediaStore.java:27)
    at org.robolectric.Robolectric.reset(Robolectric.java:1351)
    at org.robolectric.internal.ParallelUniverse.resetStaticState(ParallelUniverse.java:47)
    at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:226)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:177)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    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:50)
    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:103)
    ... 7 more

[0]

FAIL$ java -version; javac -version
java version "1.7.0_55"
OpenJDK Runtime Environment (IcedTea 2.4.7) (ArchLinux build 7.u55_2.4.7-1-x86_64)
OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)
javac 1.7.0_55

SUCCESS1$ java -version; javac -version
java version "1.7.0_51"
OpenJDK Runtime Environment (IcedTea 2.4.4) (suse-8.32.5-x86_64)
OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)
javac 1.7.0_51

SUCCESS2$ java -version; javac -version
java version "1.7.0_55"
OpenJDK Runtime Environment (IcedTea 2.4.7) (ArchLinux build 7.u55_2.4.7-1-x86_64)
OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)
javac 1.7.0_55

TRAVIS$ java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
TRAVIS$ javac -version
javac 1.7.0_51

android gradle plugin 0.8.3 + gradle-android-test-plugin 0.9.+ building error

I have tried to use android gradle plugin version 0.8.3 with gradle-android-test-plugin any of versions 0.9.1, 0.9.2, 0.9.3 and got this error:

Could not find method androidTestCompile() for arguments ....

Can you tell me what is wrong ?

There is my gradle build script below

buildscript {

    repositories {
        mavenCentral()
        mavenLocal()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:0.8.3'
        classpath 'org.robolectric.gradle:gradle-android-test-plugin:0.9.+'
    }
}

apply plugin: 'android'
apply plugin: 'android-test'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.3"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 19
    }
}

dependencies {
    androidTestCompile 'junit:junit:4.10'
    androidTestCompile 'org.robolectric:robolectric:2.1.+'
    androidTestCompile 'org.mockito:mockito-all:+'
    androidTestCompile 'org.powermock:powermock-api-mockito:1.5.1'
}

seeing test pollution between robolectric and espresso tests

This plugin has been working great then I added dagger to my application.The application and robolectric tests have different object graphs so I can inject test objects. Now when I run the espresso tests I get the following error

:dexDebugTest
:processDebugTestJavaRes UP-TO-DATE
:packageDebugTest
:assembleDebugTest
:connectedInstrumentTest
Tests on Samsung Galaxy S4 - 4.3 - API 18 - 1080x1920 - 4.3 failed: Instrumentation run failed due to 'java.lang.IllegalAccessError'

adb logcat reveals the actual error

W/dalvikvm( 3724): Class resolved by unexpected DEX: Lcom/samsung/sra/precog/PrecogApplication;(0xa4e560a8):0x976a0000 ref [Ldagger/ObjectGraph;] Ldagger/ObjectGraph;(0xa4e560a8):0x976d8000
W/dalvikvm( 3724): (Lcom/samsung/sra/precog/PrecogApplication; had used a different Ldagger/ObjectGraph; during pre-verification)
D/AndroidRuntime( 3724): Shutting down VM
W/dalvikvm( 3724): threadid=1: thread exiting with uncaught exception (group=0xa4ba9648)
D/AndroidRuntime( 3714): Shutting down VM
D/jdwp ( 3714): Got wake-up signal, bailing out of select
D/dalvikvm( 3714): Debugger has detached; object registry had 1 entries
E/AndroidRuntime( 3724): FATAL EXCEPTION: main
E/AndroidRuntime( 3724): java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
E/AndroidRuntime( 3724): at com.samsung.sra.precog.PrecogApplication.onCreate(PrecogApplication.java:24)
E/AndroidRuntime( 3724): at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)
E/AndroidRuntime( 3724): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4444)
E/AndroidRuntime( 3724): at android.app.ActivityThread.access$1300(ActivityThread.java:141)
E/AndroidRuntime( 3724): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
E/AndroidRuntime( 3724): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 3724): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 3724): at android.app.ActivityThread.main(ActivityThread.java:5103)
E/AndroidRuntime( 3724): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 3724): at java.lang.reflect.Method.invoke(Method.java:525)
E/AndroidRuntime( 3724): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
E/AndroidRuntime( 3724): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
E/AndroidRuntime( 3724): at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager( 2254): Error in app com.samsung.sra.precog running instrumentation ComponentInfo{com.samsung.sra.precog.test/com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner}:
W/ActivityManager( 2254): java.lang.IllegalAccessError
W/ActivityManager( 2254): java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
I/ActivityManager( 2254): Force stopping package com.samsung.sra.precog appid=10054 user=0

The only thing I can think is happening is that when the espresso testsuite is verified it is finding the object graph in the robolectric TestApplication because all the source in src/test is being compiled. But then at runtime is finds that it is now the actually application. This being the indicator from the logcat . Lcom/samsung/sra/precog/PrecogApplication;(0xa4e560a8):0x976a0000 ref [Ldagger/ObjectGraph;] Ldagger/ObjectGraph;(0xa4e560a8):0x976d8000
W/dalvikvm( 3724): (Lcom/samsung/sra/precog/PrecogApplication; had used a different Ldagger/ObjectGraph; during pre-verification)

I can seem to find a configuration that works around this....

Example project raises error

I am posting this here since deckard-gradle has no issues section, and it is referred to from the Readme as the best way to start.
Running "gradlew test" in deckard-gradle raises the following error:

Unable to resolve artifact: Missing:
----------
1) 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

----------
1 required artifact is missing.

for artifact: 
  org.apache.maven:super-pom:pom:2.0

from the specified remote repositories:
  sonatype (https://oss.sonatype.org/content/groups/public/),
  central (http://repo1.maven.org/maven2)


    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.MavenCentral.getLocalArtifactUrls(MavenCentral.java:31)
    at org.robolectric.RobolectricTestRunner.createRobolectricClassLoader(RobolectricTestRunner.java:145)
    at org.robolectric.RobolectricTestRunner.createSdkEnvironment(RobolectricTestRunner.java:115)
    at org.robolectric.RobolectricTestRunner$3.create(RobolectricTestRunner.java:307)
    at org.robolectric.EnvHolder.getSdkEnvironment(EnvHolder.java:21)
    at org.robolectric.RobolectricTestRunner.getEnvironment(RobolectricTestRunner.java:305)
    at org.robolectric.RobolectricTestRunner.access$300(RobolectricTestRunner.java:61)
    at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:202)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:177)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    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:50)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    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:103)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    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:355)
    at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:695)
Caused by: org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException: Missing:
----------
1) 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

----------
1 required artifact is missing.

for artifact: 
  org.apache.maven:super-pom:pom:2.0

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.resolveTransitively(DefaultArtifactResolver.java:360)
    at org.apache.maven.artifact.ant.DependenciesTask.doExecuteResolution(DependenciesTask.java:263)
    ... 45 more

Got Error: No signature of method: com.android.build.gradle.AppPlugin.getBootClasspath() is applicable for argument types: () values: []

I'm trying to test my app with this plugin but I get this error:

No signature of method: com.android.build.gradle.AppPlugin.getBootClasspath() is applicable for argument types: () values: []

this is my gradle file:

buildscript {
    repositories {
        mavenCentral()
        maven { url 'http://download.crashlytics.com/maven' }
    }
    dependencies {
        // replace with the current version of the Android plugin
        classpath 'com.android.tools.build:gradle:0.10.+'

        // the latest version of the android-apt plugin
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.1'

        // Crashlitics
        classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'

        // Robolectric
        classpath 'org.robolectric.gradle:gradle-android-test-plugin:0.10.+'
    }
}
apply plugin: 'android'
//apply plugin: 'crashlytics'
apply plugin: 'android-apt'
apply plugin: 'android-test'

repositories {
    mavenCentral()
    mavenLocal()
    maven { url 'http://download.crashlytics.com/maven' }

}

configurations {
    apt
}

def AAVersion = '3.0.1'
def ORMLiteVersion = '4.46'
def mainPackage = 'pl.grzeslowski.historia_miasta'
def paidPackage = mainPackage + '.paid'
def freePackage = mainPackage + '.free'
def adsenseTagFree = "";
def adsenseTagPaid = "";

android {
    packagingOptions {
        exclude 'LICENSE.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE'
    }
    compileSdkVersion 19
    buildToolsVersion "19.0.3"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_6
        targetCompatibility JavaVersion.VERSION_1_6
    }

    signingConfigs {
        debug {
            storeFile file("../../debug.keystore")
        }
    }

    buildTypes {
        release {
            runProguard true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'

            buildConfigField "java.lang.String", "DATABASE_NAME", "\"hstoria_miasta\""
            buildConfigField "int", "DATABASE_VERSION", "1"

            buildConfigField "java.lang.String", "PAID_PACKAGE_NAME", "\"$paidPackage\""
            buildConfigField "java.lang.String", "FREE_PACKAGE_NAME", "\"$freePackage\""
        }

        debug.initWith(buildTypes.release)
        debug {
            debuggable true
            runProguard false
            signingConfig signingConfigs.debug
        }
    }

    productFlavors {
        free {
            packageName freePackage
            buildConfigField mainPackage + ".product_flavors.MonetizationType", "MONETIAZATION_TYPE", mainPackage + ".product_flavors.MonetizationType.FREE"

            buildConfigField "java.lang.String", "AD_SENSE_TAG", "\"" + adsenseTagFree + "\""
        }

        paid {
            packageName paidPackage
            buildConfigField mainPackage + ".product_flavors.MonetizationType", "MONETIAZATION_TYPE", mainPackage + ".product_flavors.MonetizationType.PAID"

            buildConfigField "java.lang.String", "AD_SENSE_TAG", "\"" + adsenseTagPaid + "\""
        }
    }

    sourceSets {
        androidTest {
            setRoot('src/test')
        }
    }
}

androidTest {
    include '**/*Test.class'
    exclude '**/espresso/**/*.class'
}

dependencies {
    repositories {
        mavenCentral()
        maven {
            url 'https://oss.sonatype.org/content/repositories/snapshots/'
        }
    }

    compile 'com.android.support:appcompat-v7:19.1.0'
    compile 'com.android.support:support-v4:19.1.0'
    compile fileTree(dir: 'libs', include: ['*.jar'])

    // Android annotations
    apt "org.androidannotations:androidannotations:$AAVersion"
    compile "org.androidannotations:androidannotations-api:$AAVersion"

    // ORMLite
    compile "com.j256.ormlite:ormlite-android:$ORMLiteVersion"
    compile "com.j256.ormlite:ormlite-core:$ORMLiteVersion"

    // Google Guava
    compile 'com.google.guava:guava:16.0.1'

    // Joda Time
    compile 'joda-time:joda-time:2.3'

    // Crashlitics
    compile 'com.crashlytics.android:crashlytics:1.+'

    // google play
//    compile 'com.google.android.gms:play-services:4.3.23'

    // TESTING
    // Espresso
    androidTestCompile fileTree(dir: 'libs_test', include: ['*.jar'])
    androidTestCompile 'com.squareup.dagger:dagger:1.1.0',
            'org.hamcrest:hamcrest-integration:1.1',
            'org.hamcrest:hamcrest-core:1.1',
            'org.hamcrest:hamcrest-library:1.1'

    androidTestCompile('junit:junit:4.11') {
        exclude module: 'hamcrest-core'
    }
    androidTestCompile('org.robolectric:robolectric:2.3-SNAPSHOT') {
        exclude module: 'classworlds'
        exclude module: 'maven-artifact'
        exclude module: 'maven-artifact-manager'
        exclude module: 'maven-error-diagnostics'
        exclude module: 'maven-model'
        exclude module: 'maven-plugin-registry'
        exclude module: 'maven-profile'
        exclude module: 'maven-project'
        exclude module: 'maven-settings'
        exclude module: 'nekohtml'
        exclude module: 'plexus-container-default'
        exclude module: 'plexus-interpolation'
        exclude module: 'plexus-utils'
        exclude module: 'wagon-file'
        exclude module: 'wagon-http-lightweight'
        exclude module: 'wagon-http-shared'
        exclude module: 'wagon-provider-api'
    }
    androidTestCompile 'com.squareup:fest-android:1.0.+'
}

def getSourceSetName(variant) {
    return new File(variant.dirName).getName();
}

android.applicationVariants.all { variant ->
    def aptOutputDir = project.file("build/source/apt")
    def aptOutput = new File(aptOutputDir, variant.dirName)

    android.sourceSets[getSourceSetName(variant)].java.srcDirs += aptOutput.getPath()

    variant.javaCompile.options.compilerArgs += [
            '-processorpath', configurations.apt.getAsPath(),
            '-AandroidManifestFile=' + variant.processResources.manifestFile,
            '-AresourcePackageName=' + mainPackage,
            '-s', aptOutput
    ]

    variant.javaCompile.source = variant.javaCompile.source.filter { p ->
        return !p.getPath().startsWith(aptOutputDir.getPath())
    }

    variant.javaCompile.doFirst {
        aptOutput.mkdirs()
    }
}

apply plugin: 'idea'

idea {
    module {
        testOutputDir = file('build/test-classes/debug')
    }
}

IntelliJ import support

On the current HEAD this plugin, when used with the android plugin (version >= 0.9.0), does not import deckard-gradle cleanly into IntelliJ. The test runner can not find the test class; it is not on the classpath. Android Studio does not seem to have this problem.

I fixed this manually by going to the project structure > module > paths > compiler output and adding 'build/test-classes' to the empty box for the test output path (I used the absolute path). The test ran in IntelliJ at this point.

My understanding was that the 'idea' gradle plugin would take care of this, but it seems to either have regressed against newer IntelliJ builds and/or newer builds of the gradle plugins.

So anyway, this should be fixed, but in the meantime there is a not-so-horrible workaround for IntelliJ users and so we should probably release 0.9.4.

IDE night mare

Can't make Robolectric 2.3 and android-20 to play nice with Intellij 14 or 13 or Android Studio.
There are plenty of blog posts with workarounds, even telling to change orderEntry on .iml files which does not stick (with you are syncing gradle files with IntelliJ) and when it does result in NullPointerException in a Robolectric internal class.

Everything goes well from the command line.

This is my build.gradle (2.1):

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.13.3'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4+'
        classpath 'org.robolectric:robolectric-gradle-plugin:0.13.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
apply plugin: 'robolectric'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 20
    buildToolsVersion '20.0.0'

    defaultConfig {
        applicationId "com.example.app"
        minSdkVersion 9
        targetSdkVersion 18
        versionCode 1
        versionName "1.0"
    }

    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:20.+'

    androidTestCompile 'org.robolectric:robolectric:2.3'
    androidTestCompile 'junit:junit:4.11'
}

robolectric {
    include '**/*Test.class'

    maxHeapSize = '2048m'
    jvmArgs '-XX:MaxPermSize=512m', '-XX:-UseSplitVerifier'

    ignoreFailures false

    afterTest { descriptor, result ->
        logger.quiet("== Robolectric Tests ==")

        logger.quiet("\n${descriptor.name}\t:\t${result.resultType}")
        if("${result.resultType}" == "FAILURE") logger.error("\t${result.exception}")
    }

}

Release 0.13.0?

Is there a new release planned soon? 0f3a864 is particularly helpful for one of my projects.

Thanks!

"Resource not found" errors when running tests

I've started seeing "Resource not found" errors when running tests against the latest version of the plugin. I have a feeling that version 0.12.0 of the android gradle plugin moved where the resources are located, so Robolectric doesn't know where to find them.

Accessing to missing property 'destinationDir' using the latest gradle plugin(0.13.0)

I'm using a robolectric and I configured my project with the latest gradle plugin(0.13.0).
I got a message below and build failed.
No problem is happened with the previous version of gradle plugin(0.12.2 and earlier), so probably something has changed on the new plugin.

Environment:
JDK: 1.8.0_05
Gradle plugin: 0.13.0
Gradle version: 2.1

$ ./gradlew assembleDebug --stacktrace

Caused by: groovy.lang.MissingPropertyException: No such property: destinationDir for class: org.gradle.api.DefaultTask_Decorated
    at org.gradle.api.internal.plugins.ExtraPropertiesDynamicObjectAdapter.setProperty(ExtraPropertiesDynamicObjectAdapter.java:46)
    at org.gradle.api.internal.CompositeDynamicObject.setProperty(CompositeDynamicObject.java:119)
    at org.gradle.api.DefaultTask_Decorated.setProperty(Unknown Source)
    at org.robolectric.gradle.RobolectricPlugin$_apply_closure1.doCall(RobolectricPlugin.groovy:128)
    at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:59)
    at org.gradle.listener.ActionBroadcast.execute(ActionBroadcast.java:39)
    at org.gradle.api.internal.DefaultDomainObjectCollection.doAdd(DefaultDomainObjectCollection.java:164)
    at org.gradle.api.internal.DefaultDomainObjectCollection.add(DefaultDomainObjectCollection.java:159)
    at com.android.build.gradle.AppExtension.addVariant(AppExtension.groovy:48)
    at com.android.build.gradle.internal.VariantManager.createVariantApiObjects(VariantManager.java:645)
    at com.android.build.gradle.internal.VariantManager.createApiObjects(VariantManager.java:614)
    at com.android.build.gradle.internal.VariantManager.createAndroidTasks(VariantManager.java:225)
    at com.android.build.gradle.internal.VariantManager$createAndroidTasks.call(Unknown Source)
    at com.android.build.gradle.BasePlugin.createAndroidTasks(BasePlugin.groovy:444)
    at com.android.build.gradle.BasePlugin$_apply_closure7.doCall(BasePlugin.groovy:355)
    at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:40)
    at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:25)
    at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:83)
    at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:31)
    at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
    at com.sun.proxy.$Proxy12.afterEvaluate(Unknown Source)
    at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:67)
    ... 52 more

This error is occurred on the build configuration stage so that every task will fail with this problem.

Our dependencies are below.

buildscript {
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath 'org.robolectric:robolectric-gradle-plugin:0.11.0'
  }
}

allprojects {
    repositories {
        mavenCentral()
        maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
    }
}

apply plugin: 'robolectric'

dependencies {
  androidTestCompile('org.robolectric:robolectric:2.3') {
        exclude module: 'classworlds'
        exclude module: 'commons-logging'
        exclude module: 'httpclient'
        exclude module: 'maven-artifact'
        exclude module: 'maven-artifact-manager'
        exclude module: 'maven-error-diagnostics'
        exclude module: 'maven-model'
        exclude module: 'maven-plugin-registry'
        exclude module: 'maven-profile'
        exclude module: 'maven-project'
        exclude module: 'maven-settings'
        exclude module: 'nekohtml'
        exclude module: 'plexus-container-default'
        exclude module: 'plexus-interpolation'
        exclude module: 'plexus-utils'
        exclude module: 'wagon-file'
        exclude module: 'wagon-http-lightweight'
        exclude module: 'wagon-http-shared'
        exclude module: 'wagon-provider-api'
    }
}

error: package org.robolectric does not exist

Followed the instractions, Set up ok, but when I ran "gradle test" I got:
error: package org.junit does not exist
error: package org.junit.runner does not exist
package org.robolectric does not exist

etc.

Could not find property 'outputs' with 0.13.2

Hi, I see there is a new version of robolectric plugin on maven central. I try to sync my project using this version but Android Studio gives me this error:

Error:Could not find property 'outputs' on com.android.build.gradle.internal.api.ApplicationVariantImpl_Decorated@4c5d03c5.

Please note that I'm using JDK7 and 0.13.0 works well, 0.13.1 gives the unsupported major.minor error (plugin built using JDK8), and 0.13.2 gives this problem.

Intellij dependency issue

I am having issues getting the Intellij to work with some of the latest versions of the robolectric-gradle-plugin. Since the name change (0.10), I have not been able to get Intellij to find the test dependencies when I refresh Gradle.

classpath group: 'com.android.tools.build', name: 'gradle', version: '0.10.+'
classpath group: 'org.robolectric.gradle', name: 'gradle-android-test-plugin', version: '0.10.+'
...
plugin 'android-test'
androidTest {... }

But when I upgrade, intellij just spins and never finishes finding the dependencies.

...
classpath group: 'com.android.tools.build', name: 'gradle', version: '0.12.+'
classpath group: 'org.robolectric', name: 'robolectric-gradle-plugin', version: '0.12.+'
...
plugin 'robolectric'
robolectric {... }
...

I know it has something to do with Intellij because it all works from the command line.

This never goes away :(

screen shot 2014-09-22 at 5 14 41 pm

Running from the command line works fine.

I am using gradle 1.12 (which is specified in my gradle-wrapper.properties)

Cannot work with AppCompat in Gradle

I'm using:
classpath 'org.robolectric:robolectric-gradle-plugin:0.11.+'

I got this error when running Activity with AppCompat in shell:

java.lang.RuntimeException: huh? can't find parent for StyleData{name='Theme_Sanactbar', parent='@style/Theme_AppCompat_Light_DarkActionBar'}
at org.robolectric.shadows.ShadowAssetManager$StyleResolver.getParent(ShadowAssetManager.java:365)
at org.robolectric.shadows.ShadowAssetManager$StyleResolver.getAttrValue(ShadowAssetManager.java:350)
at org.robolectric.shadows.ShadowResources.findAttributeValue(ShadowResources.java:293)
at org.robolectric.shadows.ShadowResources.attrsToTypedArray(ShadowResources.java:196)
at org.robolectric.shadows.ShadowResources.access$000(ShadowResources.java:55)

'Deprecated dynamic property: "destinationDir"' warning

I'm getting this warning whenever I apply the 'android-test' plugin:

Creating properties on demand (a.k.a. dynamic properties) has been deprecated and is scheduled to be removed in Gradle 2.0. Please read http://gradle.o
rg/docs/current/dsl/org.gradle.api.plugins.ExtraPropertiesExtension.html for information on the replacement for dynamic properties.
Deprecated dynamic property: "destinationDir" on "task ':android:testDebugClasses'", value: "...".

If I comment out the plugin 'apply' then the warning goes away. Any ideas? I believe I'm on the right versions of everything:

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.10.+'
classpath 'org.robolectric.gradle:gradle-android-test-plugin:0.10.+'
}
}

ignoreFailures is ignored

On Javaland we can tell gradle to ignore test failures by doing:

test {
    ignoreFailures = true
}

This does not seem to work with the gradle-android-test-plugin.

0.9.4 fails after upgrade with cryptic error

After upgrading to 0.9.4 gradle fails with the following error:

Configuration with name 'androidTestCompile' not found.

According to @mag: "0.9.4 requires android gradle plugin 0.9.0 or greater, which changes the DSL to use 'androidTestCompile' rather than 'instrumentTestCompile'. We also pushed a new version of deckard-gradle, which illustrates how to use all of these together. Make sure to read all of the instructions in deckard-gradle, as there is now some manual setup required when importing into your IDE."

When backward-incompatible changes like this happen, the plugin should fail with a more informative error message.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.