tag:blogger.com,1999:blog-39243992706983313642023-06-20T05:56:14.265-07:00Always askingAnonymoushttp://www.blogger.com/profile/10161817390922515164noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-3924399270698331364.post-90841948258520785732013-11-12T03:31:00.002-08:002013-11-12T03:31:50.658-08:00New Android event in SevilleIf you happen to be in Seville on the 19th November 2013, don't miss this opportunity <a href="http://bit.ly/1dkLw3e" target="_blank">to take part in the first BOP ever!</a>Anonymoushttp://www.blogger.com/profile/10161817390922515164noreply@blogger.com0tag:blogger.com,1999:blog-3924399270698331364.post-83164863885658014792013-11-05T04:14:00.001-08:002013-11-05T04:14:54.785-08:00Do 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 <a href="http://robolectric.org/javadoc/org/robolectric/annotation/Config.html">reading</a> 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.<br />
<br />
So if you are getting one of these pesky exceptions:
<script src="https://gist.github.com/israbr/e3e706c7ee4afb86f03e.js"></script>
Double check that you specify the location of your AndroidManifest file in the <code>@Config</code> anotation.
Anonymoushttp://www.blogger.com/profile/10161817390922515164noreply@blogger.com1tag:blogger.com,1999:blog-3924399270698331364.post-28723546761336640792013-11-05T01:16:00.000-08:002013-11-05T01:16:28.319-08:00Debugging GradleAlways wanted to find out how does Gradle the thing it does? Is it driving you crazy not knowing why that script is not working?<br />
<br />
<a href="http://forums.gradle.org/gradle/topics/how_do_you_attach_a_debugger_to_gradle_so_that_i_can_debug_it_running_a_task">Attach a remote debugger</a><br />
<br />
<br />TL;DR<br />
<ul>
<li>Add a new system variable:<script src="https://gist.github.com/israbr/f6d5a167a38b06fa523a.js"></script></li>
<li> Start your Gradle task<br /></li>
<li>Run your favourite IDE's debugger</li>
</ul>
Anonymoushttp://www.blogger.com/profile/10161817390922515164noreply@blogger.com0tag:blogger.com,1999:blog-3924399270698331364.post-17966435030682208742013-10-28T11:00:00.001-07:002013-10-28T11:00:51.477-07:00Testing with Robolectric (I)If you have your own Application class for your Android app, you might have found your tests failing because of a class cast exception:
<br />
<blockquote>java.lang.ClassCastException: android.app.Application cannot be cast to BLALBLA class
</blockquote>
And if you are using Robolectric 2.+ the way to solve this is to annotate your test with <br />
<blockquote>@Config</blockquote>
like so:
<script src="https://gist.github.com/israbr/c4fe1f32a80f186ea318.js"></script>
<br/>You can annotate also annotate the whole suite.
Anonymoushttp://www.blogger.com/profile/10161817390922515164noreply@blogger.com0tag:blogger.com,1999:blog-3924399270698331364.post-27306456517642300532013-09-11T11:07:00.001-07:002013-09-12T10:59:06.689-07:00Get Google Play services in your app (Intellij Android Studio)You can find an easy way to get Google Play services in your project <a href="http://forum.xda-developers.com/showpost.php?p=45069732">here</a><br />
<br />
But for an even easier way, this is your safest <a href="http://forum.xda-developers.com/showpost.php?p=45069732&postcount=4">bet</a><br />
<br />
<b>UPDATE:</b> <br />
If you change update your Studio, make sure to run a clean and build. Wasted morning N+1Anonymoushttp://www.blogger.com/profile/10161817390922515164noreply@blogger.com0tag:blogger.com,1999:blog-3924399270698331364.post-13655322760347918582013-07-05T08:26:00.002-07:002013-11-05T04:35:05.518-08:00Running tests Test running startedTest running failed: Unable to find instrumentation info for: ComponentInfo{ [package.name]/android.test.InstrumentationTestRunner} Empty test suite.I have been trying to run tests using Intellij's Android Studio. So I started <a href="http://developer.android.com/tools/testing/activity_test.html">here</a> and used the IDE to help me create everything I needed. Failed horribly. Then I followed <a href="http://stackoverflow.com/questions/16682223/how-do-i-structure-project-test-directory-in-android-studio">this</a> and kept receiving this HELPFUL message:<br />
<br />
<script src="https://gist.github.com/israbr/a4ac2fcccb8548dcc1ed.js"></script><br />
like a billion times!<br />
<br />
These are the things I have learnt:<br />
<br />
<ul>
<li>Android/Studio use JUnit 3 so the constructor for your test suite MUST NOT have any parameters (aka don't let Studio create a constructor for you because it will add a parameter and JUnit will not be able to find your test suite):</li>
<script src="https://gist.github.com/israbr/cad836dddb582b8ad884.js"></script><br />
<br />
<li>Your test needs to be in: <br />
<script src="https://gist.github.com/israbr/2705d181ed59cadd6ebb.js"></script>
More <a href="http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Testing">info</a></li>
<li>The package of your test needs to be different from the package of the class you want to test, i.e: if the package for your activity is <script src="https://gist.github.com/israbr/3dc8b2e9face495df697.js"></script>
<br />then the test should be in <script src="https://gist.github.com/israbr/b87288bc0ec06ee20929.js"></script>
</li>
<li>Don't bother trying to run it from the IDE (don't believe <a href="http://tools.android.com/recent/androidstudio018released">this</a>)
<ul>
<li>Start your emulator</li>
<li>Go to <yourProjectDir> (or where your gradlew is)</li>
<li>Run <code>./gradlew connectedInstrumentTest</code> </li>
<li>The results can be found at: <script src="https://gist.github.com/israbr/75aff1f0596b9db6a2a1.js"></script></li>
</ul>
</li>
</ul>
Anonymoushttp://www.blogger.com/profile/10161817390922515164noreply@blogger.com2tag:blogger.com,1999:blog-3924399270698331364.post-90398064080959270132013-06-03T09:53:00.000-07:002014-02-17T08:42:03.727-08:00Android Studio (Intellij) can't find aapt...but it's there!!! (UPDATED)UPDATE: I have also encounter this with the following error message (it can be fixed the same way or <a href="http://stackoverflow.com/a/17410444" target="_blank">following this</a>):<br />
<br />
<span style="background-color: #eeeeee; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 13.333333969116211px; line-height: 16.666667938232422px;">db: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory</span><br />
<br />
<br />
If you are having problems with Android Studio (Intellij) when trying to run it for the first time with a message like:<br />
<br />
<span style="background-color: #eeeeee; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 13.333333969116211px; line-height: 16.666667938232422px;">android-apt-compiler: Cannot run program "PATH/TO/android-sdk-linux/platform-tools/aapt": java.io.IOException: error=2, No such file or directory</span><br />
<span style="background-color: #eeeeee; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 13.333333969116211px; line-height: 16.666667938232422px;"><br /></span>
<br />
<div>
I found <a href="http://stackoverflow.com/questions/16588969/android-hello-world-compile-error-intellij-cannot-find-aapt">this</a> (basically create symbolics links to the actual place where the files are. Didn't do anything for me) and <a href="http://stackoverflow.com/questions/2680492/aapt-not-found-when-building-new-android-app-in-netbeans/">THIS</a> which actually fix it for me.<br />
<br />
Turns out, as you can clearly read from the error message, it was a architecture problem. Aapt expects 32 bit binaries and my desktop is 64 bits.</div>
<div>
<br /></div>
<div>
With a nice:<br />
<pre class="default prettyprint prettyprinted" style="background-color: #eeeeee; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 13.333333969116211px; line-height: 16.666667938232422px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 13.333333969116211px; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="pln" style="background-color: transparent; border: 0px; font-size: 13.333333969116211px; margin: 0px; padding: 0px; vertical-align: baseline;">apt</span><span class="pun" style="background-color: transparent; border: 0px; font-size: 13.333333969116211px; margin: 0px; padding: 0px; vertical-align: baseline;">-</span><span class="kwd" style="background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: darkblue; font-size: 13.333333969116211px; margin: 0px; padding: 0px; vertical-align: baseline;">get</span><span class="pln" style="background-color: transparent; border: 0px; font-size: 13.333333969116211px; margin: 0px; padding: 0px; vertical-align: baseline;"> install ia32</span><span class="pun" style="background-color: transparent; border: 0px; font-size: 13.333333969116211px; margin: 0px; padding: 0px; vertical-align: baseline;">-</span><span class="pln" style="background-color: transparent; border: 0px; font-size: 13.333333969116211px; margin: 0px; padding: 0px; vertical-align: baseline;">libs</span></code></pre>
it should work</div>
Anonymoushttp://www.blogger.com/profile/10161817390922515164noreply@blogger.com3