Wednesday, December 28, 2011

Debug with Galaxy Nexus on Windows7

In case your adb doesn't show your new shiny Galaxy Nexus, it is probably because your OS doesn't have the required USB driver already installed.
On MacOSX everything went fine from the beginning, but on Windows 7 I couldn't manage to make it appear under the devices window (in DDMS perspective).

Then I found this thread on stackoverflow:

Just install the 26MB driver (eek!) and everything should work fine.

Sunday, December 25, 2011

How to use Bitbucket to remotely control your git projects

Bitbucket is an interesting service that allows to remotely store git and mercurial projects. It is reliable, easy to configure and free. Most important, you can have as many private repositories as you want.

In this post I'll explain how to commit and init a remote git repository on bitbucket starting from a local git repository. This is what I usually do in my projects: I start them locally, then commit locally via git and finally backup a remote copy via bitbucket.

These are the steps necessary to do that:
  • create a remote empty git repository on your account at
  • if you haven't already a local git repo, initialize your project locally by typing git init 
  • copy your standard .gitignore file in the project root directory
  • commit locally (using the commit command or with a GUI tool like gitx, gitc, or gitk)
At this point you're ready to commit remotely. First of all your local git environment must be setup to point to the remote repository:

git remote add origin https://<username><username>/sampleproject.git

Here I assume that your project is named sampleproject; you must substitute the <username> key with your bitbucket account name.

If everything goes fine, you're ready to do your first push on your bitbucket repo:

git push -u origin master

To fetch the remote project from another machine just type:

git clone https://<username><username>/sampleproject.git

Saturday, December 24, 2011

1 week with the Samsung Galaxy Nexus - first impressions

Today is one week since I've bought the first Android phone shipped with Ice Cream Sandwich, the new major OS update that has the ambition to unify the UI and the OS of Android smartphones and tablets.

The reasons that induced me to buy the Galaxy Nexus where many but the main were:

  • a brand new OS (new major Linux kernel, competely new UI)
  • some unique hardware features (720x1280 pixel screen), new sensors (NFC, barometer)
For a developer like me this new HW/SW configuration represents new challenges and potential opportunities and I wanted to be involved in such things as soon as possible.

Today I want to share my impressions as user, but in the following weeks I'll try to post some more tecnhical stuff as well.
The first thing I've noticed when I've switched on the phone is the new UI. It is really well made, very smooth. They have done a great job graphically. The screen is huge (4.65''), but the phone fits well in my jeans pockets, since it is also very slim (I think is 8mm thick) and the surface is a bit curved.
The things I like more are the special effects on photos and videos (expecially the runtime effects that can be applied to mouth, nose and eyes). But I'm sure the "wow effect" feature is without any doubt the face unlock feature. It is simply astonishing. Every time I face unlock my phone, I think "how can this be possible" and actually forget why I wanted to unlock it.
The battery life has also been improved: I often have 50% of power left when I switch it off at night, after a normal daily usage.
Another great thing is that starting with  Android 4.0, apps can be fully installed on the SD card, and this is a fundamental improvement that will allow to download hundreds of apps. This was a feature that was lacking in Android 2.x and maybe it is the main complaint I have to move against the previous version of the OS.
Lets' talk about the negative things I've noticed so far: first of all, it is a development phone; you get the updates quickly, but often the release is not as stable as one may hope for. Last week I had to manually reboot the phone a couple of times. The 4.0.1 release has a bug that prevents me to work with blank NFC tags, because the phone expects to work with already NDEF-formatted tags. I hope in a fix in the near future. Another downside I have noticed is that simetimes the UI becomes a bit sluggish. Many discussions have been made on this topic (see this interesting post by Andrew Munn and the reply made by Android guru Dianne Hackborn ) but i think the main culprit here might be the super huge display: the Galaxy Nexus shares the same HW configuration of the SGS 2, but it has twice the pixels of such phone. Plus, Android 4 has introduced some very nice animations (e.g when you switch between the home screen and the apps/widget screen) that might introduce some lags.
In conclusion, this is certianly a great phone, probably the best and most technologically advanced smartphone you can get today.

Wednesday, December 14, 2011

XCode 4.2 validating issues

Today I came across a weird behavior as I was trying to validate an app I had previously and successfully managed to archive.
The build and archiving phases went fine (no errors).
But as I tried to validate the new version of the app before publishing it to the app store, I was given the following error:

It came up XCode was compiling the app only for armv7 architectures.
I solved the issue by changing the "Architectures" voice under Projects Settings -> Setting -> Architectures. I've deleted the previous setting (it was ARCHS_STANDARD_32_BIT) and added two new lines:


Sunday, December 4, 2011

Android PowerManager and wake locks

Today I've tested the new version of my DroidRunner Android app that now relies on a background service to track gps location updates.
To my surprise when I finished my run, I've discovered that the GPS signal had been lost many times.
That was strange since with the previous versions the GPS tracking was much more precise.
After some googling I've found that I had forgot to add a wake lock that prevents the CPU from going asleep. In previous versions that was happening much less frequently maybe because I didin't had any background service and as there was always an activity running, probably would prevent the system from going in a sleep mode.

To add a wakelock just setup a new "use-permission" in AndroidManifest.xml:

<uses-permission android:name="android.permission.WAKE_LOCK"/>

Then, just decide which level of wake lock you want to have (for example, prevent CPU from going to sleep, with a PARTIAL_WAKE_LOCK).
Here is the list of possible options: PowerManager

This is the code snipped that can be used to request a wake lock:

PowerManager powerManager = (PowerManager)this.getApplicationContext().getSystemService(Context.POWER_SERVICE);
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "My Service");

Finally, request the wakelock and release it as soon as you don't use it:



Saturday, December 3, 2011

Create and push tags

When you've reached a stable version of your code and you've deployed it to users, it is a good practice to tag it.
Start by create a local tag:

git tag v1.0

Check that the tag is correctly created with:

git tag -l

Then push it to your remote repository:

git push --tags