Laur IVAN

Fix “Multiple dex files define L…” Errors

Posted by in Software

Today I got an error when building the APK: Multiple dex files define L/… My scenario is that of a project with 2 modules: a core and an app. Both modules use a plugin named androiddevmetrics, which generate some code, including a class which has the same signature in both modules. The linking (APK generation) resulted in an obvious conflict. My steps to solve this error are: Identify which package/module generates the error. The L/com/android/… will tell you exactly who the culpable is. In my case, the idea is to…read more

Material Drawer and Toolbar Options

Posted by in Software, Tutorial

The latest couple of days I’ve spent in adding the Excellent Material Drawer to one of my applications. In my case, the drawer is shown on the second activity in the workflow. Below, I’ll outline my experiments. Preamble First, the requirements are: An android application with one (or more activities) (d’oh!) and Material Drawer Code for obtaining the actionBar (v7 appcompat):

No hamburger menu The original code I had for the customisation was to hide the “back arrow” and show the logo and title:

The result is something…read more

Intercept OkHttpClient Response for Debug

Posted by in Software

I wanted to log the data retrieved by OkHttpClient for debugging purposes. After digging for a while, the process seems quite straight-forward now. First, we create the OkHttpClient:

Then, we add an interceptor:

The interceptor code is:

The main thing to remember is that one the response has been processed, you need to create a new one and return it. HTH, A little experiment: If you find this post and ad below useful, please check the ad out :-)

Access Data Files for Local Tests in Android

Posted by in Software

TL;DR: Put your data files in test/resources and access it with:

I’ve got an android application with a module performing data processing (HTML scraping in fact). This part is pure java and all its tests are in the src/test path. My particular problem is that I have a set of (large-ish) files to be parsed by the tests and I need a reliable way to access these files. I know that best practice would be to keep the files inline, but dumping 300k-ish content in strings for a 10-line…read more

GoogleApiClient .connect() Interface or Class

Posted by in Software

TL;DR: If it’s your code, check the version play services ( com.google.android.gms:play-services-*). If you’re using a library, check if the library has a version using play services >= 8.1.0. If not, you’ll need to clone and upgrade it yourself. The other day I got an interesting error coming out when running an app: ‘GoogleApiClient.connect()‘ was expected to be of type interface but was found to be virtual The reason was a backwards incompatible change in 8.1.0 where GoogleApiClient changed its signature. Moreover, it was in a library using version 7.x while…read more

Hide Apps in Nova Launcher Drawer

Posted by in IT, Tutorial

TL;DR: Select Nova Settings -> App and widget drawers -> Hide apps (scroll down bit) -> select the apps you want to hide. I’ve noticed that my app drawer started to get cluttered with stuff I’m not really using (like the Audio FX stuff). since some of the things I can’t remove (system apps and what not), the next best thing is to just hide them altogether. Steps are quite simple: Go to Nova Settings: Select the App and widget drawers entry: Scroll down a bit and select Hide apps:…read more

Add Wear Notifications to Android App

Posted by in Software

TL;DR: Use android.support.v4.app notification mechanism. Steps are: Create a WearableExtender:

Extend the notification mechanism:

Trigger the notification:

After reading various sources, I got my application to send notification to my watch using the code above. At the beginning, I thought the notifications weren’t sent. I thought I needed to enable wear in the manifest (which I did), but… notifications were sent, just the watch was on charging dock and was’t doing anything :(. To make sure things were OK, I’ve enabled vibration:

Note: You need <uses-permission android:name="android.permission.VIBRATE"/>read more

Load Glyphs with LibGDX

Posted by in Software

TL;DR: Remember to give the font loader the list of characters to render from the font! I’m trying to get a more resolution-independent mechanism to load simple shapes in place. After investigating SVG loading for several days I got nowhere. Then, I found out that libGDX actually supports vector fonts (TTF). Woo-hoo! Internally, it’ll convert the loaded font to a BitmapFont, for a specific size (if you want to use the same font with different sizes, you’ll have to load and store it accordingly). Preliminary stuff It is important (to…read more

Generate Amazon Underground Launcher Icons

Posted by in Software

TL;DR: Use (adapt) the script below to automatically generate the Amazon Underground application launcher icons. I was toying with the idea to build an Amazon Underground version of one of my applications. According to their rules, you need to: Repackage your app Name custom permissions (Lollipop) Apply Amazon Underground branding Migrate API (if necessary) Initially I looked for a way to automatically generate the launcher images through gradle. However, I could not find any way and I figured it’s easier to build a shell script. Assumptions and results The script…read more

Picking Colours for Your Application

Posted by in Software

While working to get a theme for my new app Epso View (Play and Amazon), I’ve identified two types of websites: Inspiration (like dribbble or materialup) Combinations (like colourlovers or materialui) You can use the inspiration sites to get inspired; what colours work together, would your app look light or dark… Then, you can use the combinations to get the colours together. A little experiment: If you find this post and ad below useful, please check the ad out :-)