Monday, March 02, 2009

Android emulator small bug

I wonder why Android SDK for Linux is distributed as a ZIP file, but anyway if you try to install the SDK in a multiuser environment you'll face some problems.
As usual, in a multiuser environment to avoid undesired changes to the software it should be installed as root.
Unpacking the SDK as root and then running as a normal user you receive this error

### WARNING: Cannot write user data file '/home/diego/.android/SDK-1.1/userdata-qemu.img'

if you check file permissions you can find that you can write to ~/.andrid/SDK-1.1 and userdata-qemu.img has been actually written.

So, what's the problem. Using strace to find out, we can see this

open("/home/diego/.android/SDK-1.1/userdata-qemu.img", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600) = 3
open("/opt/android-sdk-linux_x86-1.1_r1/tools/lib/images//userdata.img", O_RDONLY|O_NOCTTY|O_LARGEFILE) = -1 EACCES (Permission denied)
close(3) = 0
write(2, "### WARNING: Cannot write user d"..., 109### WARNING: Cannot write user data file '/home/diego/.android/SDK-1.1/userdata-qemu.img': Permission denied ) = 109 unlink("/home/diego/.android/SDK-1.1/userdata-qemu.img.lock") = 0
exit_group(3) = ?

qemu is reporting the wrong error, and the root of the problem is openning /opt/android-sdk-linux_x86-1.1_r1/tools/lib/images//userdata.img for reading.


Here is how to fix it

$ sudo chmod a+r /opt/android-sdk-linux_x86-1.1_r1/tools/lib/images//userdata.img
$ sudo chmod a+r /opt/android-sdk-linux_x86-1.1_r1/tools/lib/images//system.img

and everything will run smoothly.

1 comment:

Casey said...

Thank you, that totally worked for me.