Debug android-maven-plugin apps in Eclipse with DDMS

Lately, I’ve been developing Android applications with Maven support and, while it’s rather easy to mount a mature development environment with Eclipse, the usage of android-maven-plugin has brought some integration issues when debugging.

Usually, I do most of my Maven and debugging stuff in a terminal console. But others will prefer to use Eclipse! And I can understand why, since its DDMS perspective is so powerful and easy to use.  Here’s how you can do it:

  1. mvn clean package
  2. Deploy the target/xxx.apk to the device
  3. Open DDMS perspective in Eclipse
  4. Select the process you want to debug/trace
  5. There you go!

From profiling to thread debugging or simply adb logcat, you’ll have it all!

Don’t forget to configure permissions for your user to access the device. Ever hard those “?????” when issuing adb devices stating you have no permissions? Here’s how you can fix it (in Ubuntu-based distros at least):

  1. Run lsusb
  2. Check the line for your device, such as Bus 001 Device 008: ID 0bb4:0cab High Tech Computer Corp.
  3. Edit a new udev rule by executing sudo nano /etc/udev/rules.d/51-android.rules as seen bellow the bullet list
  4. Save file and issue sudo service udev restart
SUBSYSTEM==”usb”, SYSFS{idVendor}==”0bb4″, MODE=”0666
Reconnect your device and you’re done!

Debugging running APK in Eclipse DDMS

Advertisements

Xubuntu brought back the happy Linux user in me

I’m an Ubuntu user for some years now and I always enjoyed the “easy-mode” Debian flavor it’s got. But after delaying my workstation upgrade as much as I could, I knew the day would come that I’d be forced to move to Gnome 3 or Unity. The day came, and it really sucked!
I’m not going to argue why these new ways of seeing the desktop grew so much disdain in me, but I can assure you I felt quite attracted by the dark side (aka MacOS X) for my daily use and development. But then I heard about Xubuntu..

Xubuntu is Ubuntu-based and features XFCE, a old friend of mine “who” I used to have fun with back in the days when my hardware sucked – which now is totally not the case, since I’m relying on a I7 3.4GHz + 16GB DDR3 + OCZ Vertex 3 SSD disk.

And so it was, I downloaded the 64-bit alternate ISO, burned it and after 20 minutes my system was up and running. Boy, did I miss this.. you came a long way XFCE, and you still rock!
Besides lacking some of the integration I was used to in my now-gone-Gnome-days, the simplicity of this window-manager is making me really happy. In case you’re feeling the same way about Gnome 3 and/or Unity, do yourself a favor and give it a try!

Here’s some hints you may find useful. I’ll be updating this list!

  • Two DVI monitors side by side with xrandr

# Dual Monitors configuration on Xubuntu

# Monitor Order
xrandr –output DVI-I-1 –left-of DVI-I-2

#Tip: to configure it, exec ‘xrandr’ on bash to view the options by monitor

# Resolutions
xrandr –output DVI-I-1 –mode 1680×1050 –rate 60.0
xrandr –output DVI-I-2 –mode 1680×1050 –rate 60.0

# Primary Monitor
xrandr –output DVI-I-1 –primary

  • Don’t quit Pidgin when you press the close button

Don’t disable libnotify integration plug-in (if it’s not enabled by default, then enable it). You can however turn-off all options of this plug-in.

  • Dropbox support for Thunar file-manager

execute sudo apt-get install libthunarx-2-dev
and then follow the instructions available here.

Gerrit + Jenkins in LDAP environment

Today, I got Gerrit integrated with Jenkins. Even though there’s good info on the web on how to get this beautiful couple working together, I lack the explanation on how to configure Gerrit SSH for Jenkins usage when Gerrit authenticates its users on a LDAP service.

First of all, the Gerrit instance I’m working on is authenticating against the company LDAP directory. Nothing new here as LDAP users can log-in sucessfully. Now, the thing is Gerrit process is not running as an LDAP user, but rather an Unix one (local) and we need a Gerrit user (non-local) with a public SSH key for Jenkins to be able to acess the code review tool.

The confusion was set! How would I authenticate Jenkins without an LDAP user created for this sole purpose?! gerrit create-account is the way to go!

For this command to work, you must have an authenticated user in Gerrit with administrative privileges and public SSH key set.

First, let’s create a key for the user that Jenkins is going to use:

ssh-keygen -t rsa -b 2048

You should now have two new files, a private key and a public key. Never ever give the private key!! Imagining your recently created public key file is named id_rsa.pub and that you’ve got an xpto user configured in Gerrit as part of the group Administrators, let’s add thevirtual user:

cat id_rsa.pub | ssh -p 29418 xpto@gerrit.example.com gerrit create-account --ssh-key - jenkins

It should be OK now! Just install Gerrit Trigger Jenkins plug-in and configure it as described in the documentation. It won’t take more than two minutes before you’ve got Gerrit shaking hands with Jenkins 🙂

Installing Gerrit on Glassfish

Yey, I’m finally back!! This time I’ll share with you how to get Gerrit deployed on Glassfish application server and MySQL.

The pre-requisites are:

  • MySQL up and running and experience creating databases and defining privileges;
  • Glassfish up and running and the experience creating JDBC Datasources and deploying applications, including managing library dependencies for JDBC and others – in this case, you’ll need to provide MySQL JDBC driver and Bouncy Castle crypto API libraries to Gerrit.

If you’re ready, follow me now:

    1. Create a database for Gerrit
              mysql -u root -p
      
              CREATE USER 'gerrit2'@'localhost' IDENTIFIED BY 'secret';
              CREATE DATABASE reviewdb;
              ALTER DATABASE reviewdb charset=latin1;
              GRANT ALL ON reviewdb.* TO 'gerrit2'@'localhost';
              FLUSH PRIVILEGES;
    2. Download the latest version of Gerrit. By the time of this writing, it was 2.2.1.
    3. Initialize Gerrit in standalone mode (for now). Don’t forget to provide the correct MySQL configuration:
      java -jar gerrit-2.2.1.war init -d gerrit

If all goes well, you should have a new directory named gerrit with everything you need to get Gerrit running. Also, the standalone server (Jetty) should be up. Stop it:

    gerrit/bin/gerrit.sh stop

Now, let’s configure Glassfish datasource. Please, pay attention as this was where I got into problems..

  1. Create a JDBC Connection Pool with type javax.sql.DataSource and MySQL as datasource classname.
  2. Enable Ping mode.
  3. Define DatabaseName, User, Password, Server depending on what information you’ve provided while initializing Gerrit.
  4. Finally and most importantly, define both URL and Url properties to something like jdbc:mysql://localhost:3306/reviewdb?autoReconnect=true
  5. The parts in italic bold are the ones to change according to your own configuration.

Try to ping your datasource to check if it’s OK. It is? Great! Now, let’s proceed with the deployment of Gerrit:

    asadmin deploy --contextroot codereview --name gerrit-2.2.1 gerrit-2.2.1.war

It should be working now! Point your browser to http://your_host/codereview, et voilá 🙂

Gerrit working on Glassfish application server and on top of MySQL

Gerrit working on Glassfish application server and on top of MySQL

JPA 2.0 + Hibernate + Maven

This is a quick post. Well, more a personal reminder than an actual post. But, I thought it would be interesting for anyone trying to do the same thing I am, which is getting JPA 2.0 support with the latest Hibernate using Maven.

To achieve this, just add the following lines to your pom.xml:

<repository>
    <id>repository.jboss.org</id>
    <url>https://repository.jboss.org/nexus/content/groups/public/</url>
</repository>

Then, just use your favorite POM editor and add the org.hibernate dependencies as you see fit.

The short-story of an almost broken USB soundcard

This is no news to the ones that know me, but I’m a dance music addicted. And while I’ve been dj’ing for some years now, only recently have I decided to explore the world of music production and live performance. Some of my tools include the Akai APC40 MIDI controller, an M-Audio Axiom 49 keyboard and an M-Audio FastTrack Pro USB soundcard. The latter features four unbalanced outputs (RCA) and two balanced ones (TRS).

Front

Back

On my previous setup, I used to have Ableton Live 8 configured to use only the first two unbalanced outputs as I didn’t need the other two for what I was doing. But now, I want to have the ability to cue some clips before sending them to the wild, as I’ll be working with multiple external audio sources (i.e., turntable).

First things first! You need to install the official driver and activate the third and fourth unbalanced outputs. On MacOs X you’ll have a specific preference pane for that available at System Preferences. Then, you’ll have to configure the soundcard in Ableton Live! Don’t forget to activate the third and fourth outputs.

Ableton Live 8 soundcard configuration

I’m not going to explain how to enable cueing in Ableton Live. Instead, I’ll describe what was bothering me with my current setup: the third and fourth outputs were only sending noise.. very noisy noise!! After several try-outs (changing cables, reinstalling the driver, reconfiguring Ableton Live, testing in a different Macbook, etc.) I started to believe that my soundcard was faulty. Happily, I was wrong..

After much reading on the web about issues with this particular model, I found out that some guys had trouble with IRQ sharing. And then it stroke me! I’m using one of those cheap USB hubs for all my USB gear (five pieces at the moment) as my Macbook provides only two USB ports. The soundcard was connected to it. So, I simply connected the soundcard directly into the Macbook and “it just works! ™” 😀

Even that the solution is not much of rocket science, perhaps this post will help some noob like me in a similar situation.

Cheers 🙂

My new best-friend, HTC Hero!

Yey!!!

Hello fellow geeks.

Yeah, it’s true, I have one thanks to my buddy Nuno Tavares from NET7, who so gently “offered” it to me (kudos to him!). It’s only been two days since I got my hands on it, but I’m totally in love for this black beauty.

htc-hero

HTC Hero Black

You probably remember my post about the E71 vs IPhone and how happy I am (was) with that Nokia device, but after touching one of this, and having so many applications at hand, and that astonishingly cute user interface, I’m completely surrended! This Android-powered phone is a killer!

It comes with no carrier-blocking stuff, but still, as any respectful geek out there, the first thing I did was to investigate how could I make the experience better. I read that the HTC Sense UI was somewhat slow, and that an upgrade, which is expected in October, would solve that. But, curiously there is already a “preview” (of that update) in the wild!! The instructions are easy and are as following:

  1. Root your phone
  2. Download one of the two ROM images available in the previous link to the phone’s SD card
  3. The ROM comes zipped. Change its name to update.zip
  4. Boot your phone into the recovery image (press Home key and turn your phone on)
  5. Do a “nandroid backup”
  6. Wipe your phone/reset it to factory settings (it’s a new device, I didn’t lose a thing!)
  7. Select “apply sdcard:update.zip”
  8. Wait and then restart when this option is available (after upgrading)

The first boot will take some time, but it’s worth it.

Now, the phone I got is prepared to Poland/Romania/Czech Republic, and I don’t know why the update didn’t remove this and enabled me to select Portuguese (word suggestion, dictionary, etc.). The English language, though, is available and it was OK for me. Still, one good thing about this update is that there is this Custom Locale application who allowed me to set the locale to PT_pt, which changed the language to portuguese. There is no word suggestion or dictionary, though (and until there are, these functionalities are disabled!).

Also, for the portuguese reading this, I’d like to publicize one, and perhaps the only portuguese Android community, AndroidPT.

Enjoy! ..I surelly am 😀