GitHub has a setting to protect user privacy by not allowing changes to be pushed to GitHub where author email is one of the ones informed in your Settings.
-
posts
-
Fixing privacy issues in GitHub commits
-
Autosizing TextView
In order to use Android O+ autosizing functionality in the
TextView
(also using AppCompat or AndroidX versions) there is a small important thing that needs to be taken into account: both dimensions must be constrained to a fixed size. -
The case of deserialization of a Kotlin data class
Today we faced a tricky issue when trying to deserialize a
data class
using Gson.We got a report from QA of a feature “not working” for the release builds of our library. This feature is quite new, so we started the investigation by comparing it with other similar features. Tracking down the issue, it looked like the network code was not working, unable to deserialize a given object.
-
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?
-
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, though.
-
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
anddebug
buildTypes, but our app has two additional buildTypes:releaseWithLogs
anddebugMinified
. -
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 or two, or by creating new ones, while keeping all the remaining code in Java. So, interop between the two languages is almost 100% transparent. Almost.
-
Offtopic: mechanical calculators (cardboard and wood!)
A few days ago I happened to stumble with this fun article of a mechanical 4-bit calculator made in cardboard. Even if it’s quite unreliable, is interesting to see the methodical approach and all the creativity to make this work with only cardboard and marbles.
In the comments of the article there is a Youtube video of a calculator that implements 6-bit addition made in wood. It is very reliable, and it takes a completely different approach.
-
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 helps in the development and debugging of different parts of the application. But, some of this code can have unintended consequences:
- it can reveal sensitive data to a potential attacker (internal URLs, session cookies, etc.)
- it can have a performance impact in your application (excessive logging, performing operations not needed for release builds, etc.)
- it can lower the security of your application (backdoor-like features to help while debugging, that can disable certain security features, or completely bypass them, etc.)
-
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 problem occurred evaluating project ':my-project-app'. > java.lang.UnsupportedClassVersionError: com/android/build/gradle/AppPlugin : Unsupported major.minor version 52.0
-
npm install not installing all the packages
A few days ago I was trying to install a project’s dependencies with a simple
npm install
, but in the instructions I was given there was an extra step to manually install one additional package. When I checkedpackage.json
, the package was there… So, what was going on!? -
Fixing Python virtualenv on OS X
This weekend I’ve been toying with an old project I created in Django a while (~2 years) ago. The project uses
virtualenv
, as commonly happens in this kind of projects. The original project was created originally on a different machine, and migrated to the current one. Original machine had OS X Lion, I think… or Snow Leopard, not sure. The point is, the project had been migrated thought 4 or 5 major OS X versions… and Python was a different version from the original one used to create the originalvirtualenv
. -
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
-
Hilarious Git plugin: git-blame-someone-else
This Git plugin allows to change the commit author information. Super-useful to avoid to be the one to blame for bugs and mistakes. ;)
“I love git-blame-someone-else!!” -Linus Torvalds says*
*Linus Torvalds didn’t really approve of this. It’s a joke to prove it works. See his fake commit here.
-
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 plugin (instead of being a separated plugin) but on RC you need to change your Gradle file a little to keep using it.
-
FizzBuzz in CSS
The next time an interviewer asks you to solve FizzBuzz, impress them by doing it without a programming language. pic.twitter.com/oYo4iAfr8h
— Eric Wastl (@ericwastl) November 20, 2015 -
Wat
Fun moment: Wat.
-
Re-enabling Xcode plugins
Update Xcode 8 no longer supports plugins. See Alcatraz GitHub repo.
After updating my Xcode, I noticed that plugins got disabled. To reenable them, the easiest way is just “touching” all the plugin directories:
$ cd ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins $ touch *
-
Easily manage windows in OS X
I’ve been using OS X for many years already, and as my primary computer OS for almost a year. Before that, I used to spend time with Windows (like 90% of it), Linux (for server) and OS X.
There are two things that I missed after switching from Windows (last version I regularly used was 8.1) to OS X (I started to regularly use it on Tiger), being a heavy keyboard user: the way window cycling works on Windows, and Windows snap (available since Windows 7, including shortcuts).
-
Four things you probably didn't know about C++ (and C)
I’ve recently stumbled upon
this interesting postthis interesting post of curious features of C++ I didn’t know of (being a C/C++ programmer for so many years!). -
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 aRecyclerView
during a tutorial, instructing the user how to select a particular item. -
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.
-
Android compatibility with 32-bit libraries on a 64-bit device
Recently I run into a problem with an app we’re working on: suddenly it stopped to work on a Samsung Galaxy S6 Edge. It was still working on all the other, older devices. The first idea was: the app is using a JNI library, so it’s a 64-bit compatibility problem. And bingo! This was the reason… but in an unexpected way.
-
Language change detection in Android Jellybean 4.2+
In the current project I’m working on we had to detect system language change. We wanted to rely on Android configuration change mechanism, that handles this for us, but we had to do some additional state modifications beside UI.
-
Xcode switch tip
Today I’ve found a tip from Google about iOS development, on their “Route 85” Youtube video series. I always code defensively, and adding a
default
case option is one of the things you usually do on aswitch
when programming defensively. But in the case they show, this is a bad thing. When you write aswitch
statement for anenum
, Xcode will warn you if you’re missing any value, except if you rule this option out by means of adefault
. See the video for more information and an example. -
Debug Cordova apps using GenyMotion
Debugging Cordova apps using GenyMotion is fully supported. You just have to bear in mind that it behaves as a real device for ADB. So, to launch it from the command line you just have to run:
cordova run android
From your project directory. All credit must go to Nextneed on Stackoverflow.
-
Generating Repetitive CSS with Loops in LESS
Less is an amazing tool for simplifying your CSS: allows you to “extend” selectors (i.e. put selectors inside other selectors), to use mixins (i.e. a kind of “functions” that allow repeating optionally parametrized sets of CSS rules) and to use variables.
One missing feature is not having loops, for example to create a repetitive rule. Luckily enough, the language is powerful enough and there are smart people capable of taking advantage of that.
-
Converting a physical machine to VM
After many years in software development, I’ve switched machines many times. But I always tried to keep the old ones stored, just in case. Today I’ve finally decided to convert this old machines to a VM, and store only a hard disk and not the whole hardware.
-
Atomically increment a limited value in MySQL and PHP
Sometimes you need to acquire a limited resource in an atomically, concurrent way. This is what semaphores are for. But when this resource is in a MySQL row, apparently there is no straightforward way of doing it.
-
Switching to Firefox again
The other day I stumbled upon the article Windows Timer Resolution: Megawatts Wasted and to make long story short, I ran:
powercfg -energy duration 5
on my system and found that Chrome, Spotify and Naver’s Line client for Windows were making my system to increase timer resolution to 1 ms, wasting energy and making my laptop run warmer than expected.
-
Disabling right click and swipe on Windows Store Apps without using code-behind
A month ago I was working on a Windows Store project and I needed to disable right click and swipe for some grid controls. Of course, the property to disable/enable swipe is well known:
IsSwipeEnabled
. Just put afalse
there and you’re ready to go! But I could not find an equivalent property to disable right-click, andIsSwipeEnabled
does exactly what it says: disable swipe touch gesture, but has no effect on right-click (which you may expect it will, because right-click is the equivalent manipulation using mouse). -
Showing a rotation-locked activity programatically in Android
Sometimes you need an activity showing in a locked orientation (i.e. no rotation allowed), but you need to decide which orientation should be the activity display dynamically by code. In my case, I had to implement a chroma-keyed camera app and the backgrounds where either landscape or portrait. When the user tapped the background to use I had to decide the orientation and lock the new camera activity to this orientation.