Tuesday, 12 November 2013

Tuesday, 5 November 2013

Do you android.content.res.Resources$NotFoundException: unknown resource ? (aka Testing with Robolectric (II))

I assumed that one only needed to specify the location of the manifest if, like here, you were extending the Application class. After reading and failing miserably to get the most stupid test up and running, turns out that when you have BuildTypes and/or Flavours you have to explicit about your manifest too.

So if you are getting one of these pesky exceptions:
android.content.res.Resources$NotFoundException: unknown resource XXXXXX
Double check that you specify the location of your AndroidManifest file in the @Config anotation.

Debugging Gradle

Always wanted to find out how does Gradle the thing it does? Is it driving you crazy not knowing why that script is not working?

Attach a remote debugger


TL;DR
  • Add a new system variable:
    GRADLE_OPTIONS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006
  •  Start your Gradle task
  • Run your favourite IDE's debugger