Eclipse out of memory error

When using Eclipse for Android development, it can consume a lot of memory. If you’re working with multiple library projects with varying levels of target APIs and/or opening layout editors for different Android versions, sooner or later the java VM running the Eclipse IDE will run out of memory. This results in crashes, or even worse: cryptic, seemingly unrelated error messages and compilation errors.

To increase the memory available for the IDE, open eclipse.ini in your Eclipse folder and look for these lines:

...
-Xms40m
-Xmx512m
...

Change them to the following:

...
-Xms512m
-Xmx1024m
...

This should be sufficient for most development work, at least I haven’t encountered any issues since I’ve made these changes.

Share Button
Posted in Blog Tagged with: , ,

NumGuess Haxe and Jasmin

The NumGuess project has received another couple of great contributions by vbence:

  • New fully compliant Haxe version was added as the 36th implementation.
  • Jasmin version was fixed to follow the guidelines perfectly.

Keep up the good work guys, let me know if you have any other language ideas.

Share Button
Posted in Blog Tagged with:

Custom indeterminate ProgressBar on Android

The default loading circle animation on Android is a bit choppy and grey. It’s very easy to roll your own with perfectly smooth animation and a bit of colour to match your app’s branding. In this simple example I’m not using any bitmaps, just a basic shape in an XML drawable.

First you need to create a drawable resource, simply put the following XML into /res/drawable/progressbar_custom.xml:

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="4000"
    android:fromDegrees="0"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toDegrees="360" >

    <shape
        android:innerRadius="20dp"
        android:shape="ring"
        android:thickness="4dp"
        android:useLevel="false" >
        <size
            android:height="48dp"
            android:width="48dp" />

        <gradient
            android:centerColor="#80ec7e2a"
            android:centerY="0.5"
            android:endColor="#ffec7e2a"
            android:startColor="#00ec7e2a"
            android:type="sweep"
            android:useLevel="false" />
    </shape>

</rotate>

It is a simple ring shape with sweep gradient, in this case using a nice orange colour #ec7e2a. The gradient only changes the colour’s alpha value by adding an extra byte to the front: #ffec7e2a is opaque, #00ec7e2a is fully transparent and #80ec7e2a is halfway in-between.

Here's how it looks like against different backgrounds,

Here’s how it looks like against different backgrounds,

To use it in your layout, simply set the indeterminateDrawable attribute of your ProgressBar:

<ProgressBar
	android:layout_width="wrap_content"
	android:layout_height="wrap_content"
	android:indeterminateDrawable="@drawable/progressbar_custom" />

Animation speed

The rotation speed of the indeterminate progress bar is fixed at one revolution every 4 seconds, changing the duration attribute in the drawable XML has no effect. If you prefer to speed it up, you can change the toDegrees attribute to multiples of 360:

  • 720 makes one turn in 2 seconds
  • 1080 makes one turn in 1.33 seconds
  • 1440 makes one turn in 1 second

Any higher would make your eyes water. :)

Share Button
Posted in Blog Tagged with:

LucasArts games on GOG.com

The wait is over! The countdown on the front page has finally reached zero, and the first batch of DRM-free LucasArts games are on sale in the GOG.com store. The community has been wishing for this deal pretty much since the inception of GOG 6 years ago. The shocking surprise was somewhat spoiled by a leaked forum post yesterday, but I don’t think anyone minded.

Here’s a list of the first 6 games available, the first 3 of which have never been released through a digital distribution platform before:

According to the announcement, this is only the first few of 20+ titles to come. I’m really looking forward to my favourite classic adventures: The Day of The Tentacle, The Dig and Grim Fandango; and of course some nostalgic Star Wars titles, like the Rebel Assault and Jedi Knight series, and even that horrible Force Commander that I played such a long time ago. I hope non of those games will miss the line-up.

Share Button
Posted in Blog

Duplicating Android App Eclipse project

When developing an online Android app, it is easy to put in a switch whether it should run in live/test mode. After the initial live release however, there might be a need to install both versions on a single device. To create an identical Eclipse project with a different package name manually, you need to do a few steps:

  • Copy the project to a different folder.
  • Change the Eclipse project name in the .project file to be able to import it into the same workspace.
  • Load the project into eclipse.
  • Use refactoring to rename your application package.
  • Change all other references to your package, especially in the Android manifest.
  • Change app launcher know, so you’ll know which is which.

This simple windows batch file below does exactly that automatically. You no longer have to manually re-create or synchronise all changes into your test project, just run the script and build.

It uses the open source Find And Replace Text tool, or FART for short. It is a small program with no dependencies.

Don’t forget to change the variables on top and to add other things that may be necessary for your particular project. The example below assumes a standard Eclipse Android project, with the app_name variable specified in strings.xml. Read more ›

Share Button
Posted in Blog Tagged with: , , ,

NumGuess D and Go

Two more versions of NumGuess have been added: the D and Go programming languages, bringing the total up to 35 different implementations/languages. They can be found in the usual GitHub repo under numguess.d and numguess.go respectively.

These are the result of random Google searches to find new languages that haven’t been done yet. If you can think of any you’d like to see that has an easily usable Windows/Linux compiler or interpreter and can make programs that run in the command line, please let me know in the comments below. Or write it yourself by the guidelines and submit a pull request, they’re always welcome.

Share Button
Posted in Blog Tagged with:

Google Street View encounter

Google is transporting a bust of Lenin on a Friday morning in Manchester.

Google is transporting a bust of Lenin on a Friday morning in Manchester.

This is the first post in the aside category, in which I might post other unrelated rubbish that has nothing to do with anything.

Share Button
Posted in Blog Tagged with: ,

Deleting hundreds of thousands of files on Linux

A badly configured server which leaves hundreds of thousands of temporary files in a single folder is a bummer. Not being able to delete them easily is even more so. I tried the standard rm -rf ./*, but all I got was the following error message:

/bin/rm: Argument list too long

I tried to devise more clever patterns to delete them in chunks but it was just horribly slow anyway. This blog post from Hosting Blog came to the rescue with the following terminal command:

find . -name 'pattern*' | xargs rm

Poof! Four hundred thousand files disappeared in a few seconds. Awesome stuff!

Share Button
Posted in Blog Tagged with: , , , ,

Screen recording on Android 4.4 KitKat

While doing a demo of an Android app, I was looking for a way to easily capture the device screen. Turns out it’s not that simple.

There are quite a few solutions available on the Play store, but they either require a rooted device or taking screenshots resulting in choppy video at best, or a slideshow at worst. The Android emulators are also having performance issues, and not all of them have Google Play Services installed, which was required for my app.

Using a physical device, I went with Android 4.4’s built-in screen recorder that can be accessed from the command line. It usually results in a nice smooth recording, but you probably need a higher-end device. Apart from the choppy first couple of seconds, I had no issue with it on Samsung Galaxy S5 and the Galaxy Note 2 was quite acceptable as well.

Step-by-step

  • You have to install the Android SDK on your PC.
  • Using the SDK manager, download and install the platform tools package.
  • Enable developer options on the device and activate USB debugging.
  • Your device will need to be connected to the PC while recording.
  • Start/stop recording from the command line to save video to device storage.
  • Download video from device and profit.

Read more ›

Share Button
Posted in Blog Tagged with:

Upgrading Eclipse 4.3 Kepler to 4.4 Luna

Eclipse Luna logoEclipse 4.4 Luna was recently released along with Google’s Android ADT 23 upgrade. Just like the previous version, upgrading is fairly simple, although I ran into an error on one of my PCs that needed a manual fix. Some issues with ADT and the Android SDK can also be expected as some file paths changed from the previous version.

Upgrading Eclipse

The upgrade process is exactly the same as before: change your software repositories, check for updates and install them. If you’re using other repos, it is a good idea to export the URLs, just in case the repo settings get wiped after the update, which seems to happen often for me. It is recommended to install all updates to Kepler before upgrading to Luna.

Read my previous post with detailed instructions and screenshots if you’re not sure where to look, just make sure you use the new URLs listed here.

Eclipse 4.4 Luna repositories:

In case you’re using Eclipse for Android development, the ADT repo hasn’t changed:

As with 4.3 Kepler, the splash screen will not change on the first restart after the upgrade. Just restart the IDE again to confirm that you’re running the latest version. Read more ›

Share Button
Posted in Blog Tagged with: , , ,

If you find something useful, please feel free to buy me a cup of coffee.