Home > android, tools > Moving Android projects from Windows to Linux

Moving Android projects from Windows to Linux

This one had me really puzzled today.

I recently installed Ubuntu, just to see what developing for Android under Linux is like. Besides, it’s been about 10 years since I last used Linux, so I also wanted to see what it looks like these days.

I keep my source code in a remote Mercurual reporsitory, so copying my workspace from Windows to Linux was a snap (even if those are just different parttions on the same computer’s disk drives).

After doing “hg clone”, I opened up Eclipse, pointed it at my new workspace… and froze in a mixture of horror and confusion.

All my projects were marked with a red exclamation point, and the error window had a multitude of messages about Android requiring Java compiler compatibility level of 1.5 or better (… please use Fix project properties, etc.).

The confusing part was, all my projects are set up to use the workspace default for Java compiler platform level, and my just-created workspace’s setting was 1.6. Weird isn’t it?

The cause turned out to be my Java file encoding settings. Eclipse on Windows by default uses a single byte encoding for newly created Java files, which is my case is windows-1251 (Russian). Eclipse on Linux expects UTF-8. As soon as I changed my Linux workspace to use to windows-1251, and without touching those compiler compliance level settings, everything turned normal and my projects started building.

There is a bug filed in the Eclipse tracker going back to 2005 about this – whether or not Eclipse should default to UTF-8 for new files on Windows (and possibly MacOS). I’d like the default on Windows to be UTF-8, at least for Java files.

So… if you moved your Android code from Windows (and I presume, from MacOS) to Linux, and are getting the compiler compliance level error, check the encoding setting. Better yet, set up any new workspaces you create on Windows and intend to move to Linux later as UTF-8 right from the start.

Categories: android, tools
  1. January 21, 2012 at 2:48 pm

    Even Windows describes the system locale as being for programs that do not support Unicode. So what’s Eclipse doing using it?

    • Kostya Vasilyev
      January 21, 2012 at 6:56 pm

      Good question. Surprised me as well.

      There is an old, long, winded discussion on this somewhere on the Eclipse bug tracker. I certainly wouldn’t mind if utf-8 was the default, at least for Java sources.

  2. January 21, 2012 at 2:46 pm

    Or even better, to go Window > Preferences > General > Workspace > Text File Encoding, and set that to UTF-8 — and never, ever, use anything except UTF-8 unless you have to deal with some obsolete monolingual software, or you have some reason to use UTF-16 or other Unicode encoding (which is very rare).

    Unicode is 20 years old. There’s no reason anyone should be using old Microsoft proprietary codings in the 21st century, whether you’re planning to move to Linux or not.

    • Kostya Vasilyev
      January 21, 2012 at 6:53 pm

      Hi Bob, long time no see!

      Yes, of course – but at the time, I hadn’t converted all my sources to utf-8 yet. Now I do all my development under Linux (Linux Mint Debian Edition, to be exact), so it’s no longer an issue.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s