Home » Archives for David Wong

Author Archives: David Wong

David is a software developer who has worked in the UK, Japan and Australia. He likes building apps in Java, web and Android technologies.

Avoid Gradle Duplication in Multi-Module Android

When you have an Android project with many modules, you may find a lot of the gradle configuration being duplicated (often by copy and paste) across the build.gradle files in the various modules. I’ve read various ways to try to avoid this on the internet, and came across this blog post recently. This post uses the name of the module ...

Read More »

Paging Library 3 and Content Provider

I needed to display the contents of a Android content provider in a recyclerview with pagination. I also wanted to try out version 3 of the Android Paging Library (which is currently in 3.0.0.alpha2 release), but most of the sources of documentation and tutorials are targeted at accessing either a network (e.g. Retrofit) or a database. So I wrote a ...

Read More »

Is AspectJ Still Useful for Android? Part 2

In the first part of this post, I showed some ways that AspectJ would be useful in android development when it comes to testing. This final part demonstrates one way of incorporating AspectJ, and how I manage to make the aspect weaving somewhat configurable in the build process. Android + AspectJ A search on the internet will show that there are various ...

Read More »

Is AspectJ Still Useful for Android? Part 1

For Java projects I sometimes use AspectJ for various tasks, but for Android projects I initially decided against using it. There were various reasons for that: The structure of an Android project, and its build process, was already a lot more complicated and slower than for generic Java projects.For Android development, only compile time weaving is supported for AspectJ, which ...

Read More »

Checking for Artifactory in a Jenkins Pipeline

One of my projects uses the Artifactory as the repository manager. Unfortunately when doing a Jenkins pipeline build, I sometimes forget to ensure the Artifactory server is up first and find the job has failed after running for a while. I’ve added some script to my Jenkinsfile that will check for the Artifactory server early on and fail fast if ...

Read More »

Espresso Idling Resource for RecyclerView Data Changes

I was having a problem with using Android Espresso to test a RecyclerView when it’s data was updated. This is for an Android app where a list of contacts is displayed by a RecyclerView. There is a SearchView in the action bar that can filter the contacts list to display matching contact names. The Espresso test ran like this: Start ...

Read More »

Restart Android Activity with ActivityScenario

I was writing an instrumentation test which required restarting the activity during a test. As I was trying out the ActivityScenarioRule to replace an ActivityTestRule, the documentation says I can use this method on the ActivityScenario to restart the activity after it has been launched: 1 scenario.recreate() So I wrote this function to for restarting the activity: 1 2 3 ...

Read More »

Update Your Fake AndroidInjector

Using Dagger 2 for dependency injection means that you can inject fake / mock objects for testing. I had been using a fake AndroidInjector to do this in my Espresso tests for an old Android app I was updating, but found that on updating Dagger to a more recent version (from 2.14 to 2.21) the custom AndroidInjector no longer compiled. The ...

Read More »

Crashlytics and Android: Clean Way to Use Custom Crash Reports?

I was implementing Firebase Crashlytics for crash reporting for an Android app, and came across their documentation for customizing the reports. Having things like additional logging and user info for non-fatal exceptions are great, but what I wanted to use were the custom keys that could be used to log application state when the exception occurs. What’s really nice is that the state info is clearly displayed in the Firebase console. My ...

Read More »