Layout inflation and why AppCompat components replace standard ones

Some time ago I saw the following question in StackOverflow: Why does Android select AppCompat components when I don’t declare them explicitly? I was debugging my App and found while hovering on an ImageView reference that, it is an AppCompatImageView instead of an ImageView. The same happened with a TextView(with AppCompatTextView). So, why Android Views get “automagically” converted into AppCompat* equivalents? The answer […]

Android compatibility with 32-bit libraries on a 64-bit device, updated

Sometime ago I wrote the following post: Android compatibility with 32-bit libraries on a 64-bit device. In that article, the proposed solution was to manually remove the library files that were causing the problem using exclude. See that article for the details on the reasons to do that. There’s a better way using ABI Filters, […]

How to specify different buildTypes in Gradle 3.0.0 beta 4 and later

After updating to Gradle plugin 3.0.0 beta 4 our build failed with the following message: buildTypeMatching has been removed. Use buildTypes..fallbacks Our libraries have release and debug buildTypes, but our app has two additional buildTypes: releaseWithLogs and debugMinified. Snippet of our app Gradle file: android { // … buildTypeMatching ‘releaseWithLogs’, ‘release’ buildTypeMatching ‘debugMinified’, ‘debug’ buildTypes […]

Kotlin interop: mixing Kotlin and Java ButterKnife-annotated activities

I’ve been working with Kotlin for a while, mainly for side-projects or toy-projects. Since last Google I/O 2017 announcement it has become clear that there are no more reasons or excuses to not use it in production. One of the big selling points of Kotlin is that you can start small, by converting one class […]

Disabling (and removing) code on release builds

Repo updated on 2017-03-13: added additional debug configurations to check different options to enable/disable minification, optimization and obfuscation. See the discussion in Optimize without obfuscate your debug build, including this comment. Sometimes you have to add code to your applications that is used for debugging purposes. This can be very useful, and sometimes is keep there as it […]

Jenkins builds with a different Java version

We have a Jenkins server taking care of CI for an Android project. In the server we were using Java 7, but since we updated a few dependencies we needed Java 8 to run some Gradle plugins. After the change, we suddenly started to get this error in the builds: * What went wrong: A […]

Problems with Instant Run (Android Studio 2.0 beta 4) and Retrofit

This morning I was playing with a toy app I have which uses Retrofit, and I’ve found the following problem with it (and Instant Run): 02-16 07:41:55.550 2976-2976/com.test.android A/art: art/runtime/thread.cc:1329] Throwing new exception ‘length=227; index=1017’ with unexpected pending exception: java.lang.ArrayIndexOutOfBoundsException: length=227; index=1017 The exception was in the call itself, so it was either Retrofit doing […]

Kotlin RC and kotlinx

I’ve been toying with Kotlin for a while. Yesterday RC was released, making it one step closer to have a stable version. One small change that has made me scratch my head a little, even if I read the solution, has been the changes regarding Kotlin Extensions. This had been integrated with the main Kotlin […]

In-depth article on Android touch events handling

Sometimes you need to intercept touches for a given ViewGroup, to temporarily change or disable it’s behavior. For example, recently I had to do this to temporarily intercept events for a RecyclerView during a tutorial, instructing the user how to select a particular item. In this case, I could simply add an overlaid Layout on top […]

Disabling logs on Android using ProGuard

A quick way of disabling the logs for release builds is using ProGuard to take care of it. To do it in our current project we’ve created two ProGuard configurations, the one that applies for all the builds and the one that only applies for the release build. Then, we can configure the build.gradle file […]