Wednesday, February 20, 2013

Solution: Emulator Failed to allocate memory: 8...

I have started my AVD from eclipse, suddenly I faced an exception:

[2013-02-20 09:18:12 - Emulator] Failed to allocate memory: 8
[2013-02-20 09:18:12 - Emulator]
[2013-02-20 09:18:12 - Emulator] This application has requested the Runtime to terminate it in an unusual way.
[2013-02-20 09:18:12 - Emulator] Please contact the application's support team for more information.

The error occurred due to less amount of physical RAM.

Solution is to edit C:\Users\<user>\.android\avd\<avd-profile-name>.avd\config.ini and change the value 


hw.ramSize : Device ram size : The amount of physical RAM on the device, in megabytes. Default value is "96".

Monday, February 18, 2013

Solution: Invalid payload item type onMenuItemSelected

If you're developing for Android 2.3 or lower, users can reveal the options menu panel by pressing the Menu button.
On Android 3.0 and higher, items from the options menu are presented by the action bar as a combination of on-screen action items and overflow options. Beginning with Android 3.0, the Menu button is deprecated.

You have a sample code in 2.3, which is working fine for MENU option.

    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(, menu);
        return true;
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle item selection
        switch (item.getItemId()) {
                return true;
                return super.onOptionsItemSelected(item);

But there is a following exception when you have run same code in 4.0+ version

java.lang.IllegalArgumentException: Invalid payload item type
at android.util.EventLog.writeEvent(Native Method)
at android.widget.AdapterView.performItemClick(
at android.widget.AbsListView.performItemClick(
at android.widget.ListView.performItemClick(
at android.widget.AbsListView$
at android.widget.AbsListView$
at android.os.Handler.handleCallback(
at android.os.Handler.dispatchMessage(
at android.os.Looper.loop(
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(
at dalvik.system.NativeStart.main(Native Method)

Override onMenuItemSelected, and use return true or false than super.onMenuItemSelected(featureId, item).

Wednesday, February 6, 2013

Mac: Change root password without old password

If you don’t have access to an administrator already, you need to acquire root access.

If you don’t have admin access, boot the computer into Single-User Mode by holding CMD+S on startup, mount the drive, and type the command:

Wait until you see a bunch of white writing scrolling by on a black screen. You can release the keys, and you are now in Single-User mode. The computer is ready to continue when you see localhost:/ root# or something similar as the very last line on the screen.

Then follow the steps to reset admin password without old password
 /sbin/fsck -fy
        This command is a 'File System Consistency Check' and works very much the same way as Disk Utility's 'Repair Disk' function.
  /sbin/mount -uw /
        The mount command gives us access to the files on the system so we can make changes.
 launchctl load /System/Library/LaunchDaemons/

 and finally:
        Then, enter your new root password when prompted twice. After the password has been reset, type:
        this command restarts the computer.