Build fails when updating to 'com.android.tools.build:gradle:1.1.+'
lapastillaroja opened this issue · 7 comments
Android Studio 1.1 beta 3 was released and also the version 1.1 of the gradle plugin.
After change it to 'com.android.tools.build:gradle:1.1.+'
from 1.0.+ can't build anymore.
This is the error message
Error:(134, 0) No such property: bootClasspath for class: com.android.build.gradle.AppPlugin
From the 1.1.0 rc change log
Unit testing support. Unit testing code is run on the local JVM, against a special version of android.jar that is compatible with popular mocking frameworks (e.g. Mockito).
Wonder how it affects this plugin
Yes, they changed the API for that method. Also they are now supporting unit tests so I won't take the effort to make it work for a version that is supposedly supporting them natively. If their tests don't work quite as expected then either file a report to the tools team or keep using version 1.0.0.
I guess this plug-in is closing to its deprecation
@SuperJugy: This should be re-opened. Yes, Gradle plugin 1.1 has unit test support, but it is not Robolectric unit test support. It uses a fudged-up android.jar which returns default values. It requires mocking to do virtually anything, which Robolectric does differently.
For anyone using Robolectric for their unit tests, they either have to rewrite them to take out Robolectric stuff, or never upgrade to anything beyond gradle plugin 1.0.1 (which at some point in time Google will force you to upgrade!).
I really feel that your plugin is needed. That being said, you should be able to remove a lot of the functionality as gradle 1.1 already provides running the tests inside the host JVM - it may be as simple as hooking into this classpath to set it up for Robolectric instead of their fudged-up android jar.
Even so, as you say, adding Robolectric should be a classpath hack. Having a whole plugin just to hack a classpath sounds like overkill. My suggestion would be to file a issue with Google's tool team and ask if they can add some configuration options to allow Robolectric tests. Or ask Robolectric team for a way to just depend on their library and make it magically work. I understand this plugin says that it is prepared for Robolectric, but more importantly, this plugin was to allow unit testing in a JVM, the Robolectric part was a plus. Considering that Google's plugin now does exactly that, there is no much point for a new plugin. Also, what if this new Android.jar is a better solution than Robolectric? Or becomes the official unit testing supported by Google? If they put enough work on it, maybe even Robolectric won't be needed.
Looks like we need no plugins anymore. With the new experimental unit test feature we can easy use robolectric. See the example https://github.com/nenick/AndroidStudioAndRobolectric or read a step by step guide http://nenick-android.blogspot.de/2015/02/android-studio-110-beta-4-and.html
@nenick: see robolectric/robolectric-gradle-plugin#128 - the robolectric plugin now seems to support v1.1 and sets up the proper configurations apparently.
I tried the robolectric/robolectric-gradle-plugin with the mentioned change now. I hope you have more luck than me. I still need to do the same stuff like without this plugin to get my test running on command-line or inside Android Studio. Maybe i did something wrong.