Saturday, 28 December 2013

"Collect preferences failed" eclipse ADT error

Today I updated my Android SDK in eclipse to the last version using the Android SDK Manager.



After the update was over, eclipse console was giving me this error message:

[2013-12-28 10:45:08 - Framework Resource Parser] Collect preferences failed, class java/lang/AutoCloseable not found in C:\Users\<username>\android-sdks\platforms\android-19\android.jar

Well I solved it simply by updatng the ADT eclipse plugin to the last available version.
In eclipse open: Help > Check for updates and let it work, then accept the new software to be installed.

Hope it helps somebody else!

Monday, 21 October 2013

Android Packages Organization

I like my stuff to be organized, in the same way I like my code to be organized. Here's the structure that I usually adopt for my Android projects:

  • com.<company-name>.<project-name>: The main package, here I store only the Application class. All following packages will be sub-packages of this one.
  • .gui: Contains all the classes related to UI management. Usually this package is empty, the content is organized in sub packages.
  • .gui.activities: Contains all the Activity classes.
  • .gui.fragments: Contains all the Fragment classes.
  • .gui.views: Contains all the View classes.
  • .gui.adapters: Contains all the Adapter classes.
  • .gui.dialogs: Contains all the Dialog definition classes.
  • .gui.support: Contains all the UI related classes that doesn't fit in previously described packages.
  • .domain: Contains all the java beans that represents the application domain.
  • .domain.enums: Contains all the enumeration files related to the application domain.
  • .core: Contains all the core logic classes. These classes form a layer that services the UI classes managing local storage, web service connection, data elaboration, ...
  • .db: Contains all the database management classes.
  • .db.tables: Contains all the database table definition classes.
  • web: Contains all the web service communication classes.
  • web.messages: Contains all the message definition classes.
What do you think of it? Every comment or suggestion is welcome.

Tuesday, 27 August 2013

Google Spreadsheets - Count word occurrences

I'm a big fan of Google Docs, I think it is an incredible collaboration tool, however it got problems...


Today I was working on a spreadsheet and I wanted to count the occurrences of a word in a cell interval, this should be a simple task, right?
Infact, there's a useful function named COUNTIF(interval, criteria) that does exactly this, in interval you specify the cells to be checked, in criteria you specify the number, string or cell that you want to count in the specified interval. The only problem was...it wasn't working! It just said me #ERROR and asking for more details resulted in a generic "Analysis Error".
After some research I discovered that the problem was simply that, as a parameter separator, the comma works only in the US, for other countries you have to use the ";"!
So the right syntax is: COUNTIF(interval; criteria).
Here are some working examples:
  • =COUNTIF(L5:L450; "OK")
  • =COUNTIF(L5:L450; D45)
  • =COUNTIF(L5:L450; 12)
Bonus tip: if you want to count not empty cells use the COUNTA(interval) function!

Sunday, 25 August 2013

Configure Assembla GIT repository in eclipse (Windows)

Today I found out that setting up eclipse on a Windows system to connect to an Assembla GIT repo is not really straightforward. I'll try to guide you step-by-step to the environment set up, I take for granted that you have already created your Assembla project and that you've already have your eclipse project in a local GIT repository that you want to push on Assembla.

Key generation

First of all you have to generate a pair of private/public keys. You can do this from inside eclipse going in "Windows>Preferences>General>Network Connections>SSH2". Select the tab "Key Management" and then "Generate RSA Key...".




This will create a pair of public/private keys to be used for SSH. Now, without choosing a passphrase, save the private key on your PC in the directory "C:/Users/<Username>/.ssh" (Unless you have changed eclipse defaults stated in the SSH2 "General" tab). Copy to clipoard the public key string as it is in the text box, you'll need it to configure Assembla.
Select "Apply" and close the dialog with "OK".

Assembla configuration

Open your Assembla profile page and go to the tab "Manage SSH Keys". Here paste the public key you have copied before and add it with the "Add" button.


Now go to your project page and select the "Git" tab, Assembla should give you the repository url. Something like that: git@git.assembla.com:<project-name>.git, copy it in the clipboard, you'll need it to configure eclipse.

Remote repository creation

Return to eclipse and go to the GIT Repository Exploring perspective, select your local GIT repository and right click on the "Remotes", and select "Create Remote...".


Select the remote name and then go on, "origin" is the default. Eclipse will ask you to cofigure the push settings.


Select "Change..." near the URI field. Eclipse will show you a new dialog.


Paste the address you have copied from Assembla in the URI field, select SSH protocol and leave "git" as username. Confirm and close all the dialogs, if you select "Save and Push" your project will automatically be pushed to Assembla, otherwise you can do it later manually.

You should now be able to work with your Assembla GIT repository.
Let me know if this works for you also.

Note: Tested with eclipse Juno and EGit 2.3.1

Monday, 5 August 2013

Eclipse failing during Android "export signed application package"

Sometimes eclipse fails while processing the "export signed application package" for Android. The fail can appear as a generic error message “Conversion to Dalvik format failed error 1” or as a complete crash of the  IDE.

Even restarting eclipse doesn't seem to fix the problem. A simple solution I've found that works for me is this one:

  • Disable automatic project building
  • Clean the project
  • Export the package
  • Re-enable automatic building
This seems to work on both, Mac and Windows version, of eclipse.
Let me know if this works for you also.

Sunday, 4 August 2013

Samsung Galaxy Nexus problems


Screen turning on automatically

This morning my Galaxy Nexus decided he didn't want to stand by. Every time I locked the screen, it turned on again automatically. Well, after some research it turns out that this can be a software or an hardware problem. Some people resolved the (SW) problem with a  factory reset of the device, i haven't tried...
In my case it was a simple HW problem, because i solved it with some simple steps:
  1. Turn off
  2. Take out the battery
  3. Blow with strong inside the power plug
  4. Take a wooden toothpick and gently clean the plug
  5. Wait a couple of minutes
  6. Insert the battery
  7. Turn on
In a few words it was just dirty...

While doing this, check also the orientation of the male part of the USB connector, it should be coming out straight, it shouldn't bend down or up. If it does, try carefully to bring it to a straight position using the toothpick or a small screwdriver.

If this didn't solved your problem, and you have no fear to open your phone, you could buy a replacement connector board on eBay for something like 10$.

Phone not charging

Since I'm at it, some time ago I faced another problem related to the power plug that prevented the phone from charging. The male part of the connector was bend down, making it straight (as described before) solved the problem.

GPS not fixing

Another problem I've experienced is the malfunctioning of the GPS receiver, it started all of a sudden, without apparent reason. All the location based application wasn't fixing the signal, the GPS icon would just blink forever.
What I did was simply to turn off the phone, remove the battery, wait some seconds and then turn it on again. Then it started working properly.

Hope this helps, let me know.

Sunday, 12 May 2013

A new form factor of electric mobility

I've stumbled upon a very interesting electric vehicle, here are the main characteristics:

  • Cheap to build
  • Light
  • Compatible with public transport
  • Recharged in only 15 min. on a standard power plug
  • 20 MPH
So the question is: why not?

Here's the TED video.
Here's the company website.

Friday, 3 May 2013

Samsung Galaxy Young problems




I'm an unlucky owner of a Samsung Galaxy Young (AKA Galaxy Y), a (very)low-end device. During use of this device I've faced some frustrating problems like phone that reboots automatically or network connection disappearing until you rebooted it. Adding the ridiculously short battery life it was just unusable.
I've looked for a solution to the problem, and found it in the "Use only 2G networks" option, that can be found under "Settings > Wireless and networks > Mobile networks". Now I have no more reboot or network problems, and I count stand-by battery life in days, not hours! If you haven't got a data connection, or if you are OK without a 3G one, give it a try!

Sunday, 28 April 2013

Picasa duplicate contacts

OK, Picasa got a really frustrating problem in contacts management. I also thought about switching to another service...

The problem is that for some reason you find a lot duplicates of your contacts, and even duplicates of duplicates sometimes! This is probably happening if you tag people in different Picasa installations or from the web and from the PC client. I hate this kind of mess, so I spent my afternoon looking for a solution, here's what I came up with (tested with Picasa 3.9).

0 - Look for duplicates in your contacts
The first thing you should do is to clean your Google contact list from duplicates. Simply go to Google Contacts and choose More > Merge Contacts, this option will show you couples of possible contact duplicates, giving you the possibility to merge them. Clean your contact list from all duplicates and go on...
More information on this step here.

1 - Add an email address to all your contacts
Part of the problem seems to be related to contacts that doesn't have an associated email address, so the first thing I've done is to set to every contact in your Google Contacts page an email address. If you haven't got the real email address of one of your contacts just use a fake one. I've used the format <name>.<surname>@fake.com, just to remember that is not the real address (I've also set a custom label named Fake to all the fake addresses).

2 - Sync your Picasa contact list with Google
Launch your Picasa installation (if you haven't got the latest version update it first!) and open the People Manager (Tools>People manager...). Now sync your Picasa contacts with the Google ones selecting Update.
(Sorry, I've got the italian version)

Wait until the sync is done, then Picasa could start syncing photo tags, let him finish before going on.

3 - Find duplicates on the Picasa contact list
Ok, now with a lot of patience look in the Picasa contact list for duplicates and take note of all of them. Where possible you can also delete some of the duplicates directly from this list (delete the ones with less associated photos). You could find less duplicates than the ones listed in people management, I still have to understand why...

4 - Remove duplicates from Picasa contact list
Close Picasa and open with a text editor (if you haven't got one I suggest Geany) the Picasa contacts.xml file from location C:\Users\<username>\AppData\Local\Google\Picasa2\contacts, this is the file where Picasa stores it's contact list. Make a copy of that file and store it somewhere, just in case something goes wrong. Now take your duplicates list and find all non necessary entries in the list into the XML file (Ctrl + F is your friend...). Before deleting them look which one is the one to keep! Delete the ones without email addresses, or with less information.

5 - Keep it clean
Open Picasa again and check the result, you shouldn't have duplicates anymore. Now, every time you've got to add a new person don't do it from Picasa! Open your Google Contacts page and add it (specifing an email address), then sync your Picasa contact list with Google and use the synced contact for assigning new tags.

6 - Tough ones
Despite all the work we've done some duplicates could still be there. Well, find these contacts and select all the photos associated to them and delete the associated face tags, in this way you'll have duplicates in your Picasa contact list, but they won't show in the people albums.

Hope this helps! Let me know!

2013-05-03 - Added steps 0 and 6.

Saturday, 27 April 2013

Hello World!

Hello World! Just like a good developer always does with a new language or development tool, here's my hello world.



Today I said to myself: "you face a lot of problems each day (a part of them related to development or computer issues, the other part related to your personal life xD), why don't you write about problems you solve on a blog, so maybe you'll help somebody solve they're problem faster than you did!" (other good reasons are: 1 - Practice my really bad english, 2 - Remember to my-self how I solved a particular problem xD).

So here I'm, hope you'll enjoy it and find something useful... ;)