BUILD FAILED /home/ubuntu/Appinventor/appinventor/build.xml:50: The following error occurred while executing this line: /home/ubuntu/Appinventor/appinventor/appengine/build.xml:581: Java returned: 137
Does the given directory (it hasn't displayed the full one) have any spaces in it?
Including spaces in pretty much anything in directories while using App Inventor will cause it to break down; this is a known issue.