Ubuntu: make ADB see your mobile device

If you are making an Android application it's good to test it on the real device while still in the middle of developing process. Probably the best way to do that it to just connect your mobile phone by USB cable / charger to the PC.

Now in order to make it work first thing to do is to prepare your phone:
1. Turn on the "Developer Options" in your mobile phone
2. Set 'Stay awake' // this is not required but makes life easier
3. Set 'USB debugging'

You may notice there is no such thing as "Dev Options"... if so you will need to "google" it up how to enable it for your particular phone.
For instance on Motorola Moto G you need to do the following:
  • Go to Settings
  • Go to About phone
  • Find the 'build number' field and tap on it 7 times (LOL:)

Once done you can verify if your ADB (usually available in android-sdks/platform-tools) can actually see the device by running the following command:
> adb devices
// if everything is good you should see the ID of your device

If something is not quite right you will not see your device or you will see something weird like for example:
?????????? device

Following steps should help.
1. Query your USB:
> lsusb
// locate your device - you should see something like this:
Bus 001 Device 006: ID 11a8:2d77 Motorola PCS
where:
11a8 is vendor id
2d77 is product id

2. Create a new file for rules:
> sudo gedit /lib/udev/rules.d/10-adb.rules

// with the following content (one line)
SUBSYSTEM=="usb", ATTR{idVendor}=="11a8", ATTR{idProduct}=="2d77", MODE="0600", OWNER="your_username"

3. Restart the ADB server:
> sudo adb kill-server
> sudo adb start-server

4. Check if you can see your device:
> adb devices
ZX1E34GW9Z    device

Done! Now you should be able to run your apps directly from your dev IDE/env.

Hoper that helps.


Linux: GRUB rescue how to

There are few scenarios when your system may stop launching due to GRUB misconfiguration.

For example what I did recently was to extend the Ubuntu root partition using the live cd. It went well and my partition was bigger. The only problem was the GRUB boot loading was no longer working.
Cause of this was that the partition was also moved and drive letter changed from /dev/sda6 to /dev/sda5.

There are at least few ways to fix GRUB issues:
So in this article will cover how to fix it manually which doesn't require any third-party tools. You are running this at your own risk so if you are brave enough follow the steps below:

1. Start - you should end up seeing GRUB rescue console. Do the ls to see what drives are available:

grub rescue> ls
(hd0), (hd0,msdos6), (hd0,msdos1) ...

2. Find which drive has the boot/grub directory by running ls command to locate correct one:

grub rescue> ls (hd0,1)/
Not found...
grub rescue> ls (hd0,5)/
Found list of directories... e.g. etc/ boot/

Note: (hd0,5) in this case relates to /dev/sda5 drive

3. Find the latest version of vmlinuz core and corresponding initrd image within the boot/ directory:

grub rescue> ls (hd0,5)/boot/
vmlinuz-3.13.0-27-generic
initrd.img-3.13.0-27-generic

4. Set the prefix by running the following command

grub rescue> set prefix=(hd0,5)/boot/grub

5. Install mods:

grub rescue> insmod (hd0,5)/boot/grub/linux.mod
// not found? try locating it in other place
grub rescue> insmod (hd0,5)/boot/grub/i386-pc/linux.mod

// install additional mods
grub rescue> insmod part_msdos
grub rescue> insmod ext2
grub rescue> insmod gzio


6. Final step - run the following commands:

// note: sda5 relates to the drive where grub is available so you may have it on a different one
grub rescue> set root=(hd0,5)
grub rescue> linux /boot/vmlinuz-3.0.13-27-generic root=/dev/sda5
grub rescue> initrd /boot/initrd.img-3.0.13-27-generic
grub rescue> boot


You system should be starting. All you need to do now is to fix the grub inside the running OS - run the following:

xuser@xsystem> sudo update-grub
xuser@xsystem> sudo grub-install /dev/sda



Done! Hope that helps someone.