Part Four – Installing the Android SDKs and Appcelerator’s Titanium Mobile Developer

Hello and welcome back for part 4 (hopefully the last part!) of how to setup Appcelerator Titanium Mobile Developer on Ubuntu 1010 32-bit. These steps should also work with Titanium Desktop Developer, although you would have to downlaod that instead of the Mobile version, and probably would not want to add the Android SDK. In this final part we will add the Android SDK’s and finally install Titanium, in the previous parts we have configured a clean Ubuntu 10.10 installation so that all dependencies for Android development are installed and ready to go before we start coding. I got destracted and have started another post about getting The Elder Scrolls Arena and Daggerfall working on Android the last couple of days (should have a post on that a day or two after this one is up). And, off we go, lets get this post finished!

  1. sudo mount -a – make sure our shared drives are properly mounted
  2. let’s download the Android SDK and AVD Manager! – http://developer.android.com/sdk/index.html – The currently available download is android-sdk_r10-linux_x86.tgz, if you are using the default firefox that installs with Ubuntu 10.10 it will save it under ~/Downloads if you want to save a step, don’t save it, just open it with the archive manager and extract the contents to ~/Downloads.
  3. back to our friend the terminal sudo mv ~/Downloads/android-sdk-linux_x86/ /opt/android-sdk/ this will allow you to move the SDK plus AVD manager to the /opt directory, remember to use the [tab] key!
  4. cd /opt/android-sdk-linux_x86/tools/ && sudo ./android – this will move us into the directory and launch the AVD manager
  5. select Available Packages from the left column
  6. click the arrow next to Android Repository, this will expand the currently available choices
  7. I will be starting with 2.1; however I will also add 1.6, 2.2, 2.3.3, and 3.0 SDKs at this time, (you need 1.6 because Titanium looks for it by default and won’t let you set your preferences without it) also I am getting all of the samples, as there is no reason to reinvent the wheel, just the method used to turn it!. I also went under third party and grabbed the google api’s for 1.6, 2.1, 2.2, 2.3, 2.3.3, and 3.0 for the same reason, while under the third-party section, make sure to get the two google market Apis at the bottom. I also retrieved the Api 11 documentation (Android 3.0) (if you are interested there is also a samsung galaxy SDK there, but it is only for Android 2.2r1 for some reason)
  8. click on install selected and a new screen pops up
  9. click the “Accept All” radio button and hit install, this might take a bit… mine downloaded at 2.0 – 2.5mb/s so it was under 5 mins to d/l all of it
  10. You will be prompted to restart ADB, you must do so to continue. then close the application window.
  11. vi ~/.profile – edits your start up preferences
    1. [ctrl+f] [ctrl+f] – moves you down two pages, or in this case to the last line of the file
    2. A – starts editing the line from the end
    3. :/opt/android-sdk:/opt/android-sdk/tools:/opt/android-sdk/platform-tools – adds the android SDK directories to your path
    4. [esc] – ends editing and returns you to command mode
    5. :wq! – saves, then quits the vi editor
  12. sudo ln -s /opt/android-sdk/platform-tools/adb /opt/android-sdk/tools/adb – also needed for titanium, until they update to reflect the new home for adb!
  13. cd ~/android/environment/system && sudo wget http://www.appcelerator.com/download-linux32
  14. go to the Places pulldown menu in Ubuntu –> home folder
  15. then when it is open go to android –> environment –> system
  16. right click on the file download-linux32 and selct extract here – when I tested this, the extraction failed, when I went to the website and followed the prompts to get to the download, it downloaded the same file from the same server path and it was the same size, but the extraction worked. just an fyi if you have issues with these steps
  17. cd Titanium\ Developer-1.2.2 && sudo ./Titanium\ Developer – again remember to use the [tab] key after typing the first couple of letters
    1. on the installer screen, click on the “Install to my home directory” and change it to “Install to /opt/titanium”
    2. click Install
    3. after this ends you should get dumped to the terminal window with an error, so now we will fix that error
      1. cd /opt/titanium/runtime/linux/1.0.0 && sudo mkdir backup && mv libg*-2.0.* ./backup/
  18. cd ~/android/environment/system/Titanium\ Developer && sudo ./Titanium\ Developer – use that [tab] key!
  19. after you log in, or sign up, you should get prompted for an update to 1.6 (no idea why it downloads 1.2.2 instead of 1.6 to begin with, but hey, what can you do?), go ahead and get it, remember to install it to /opt/titanium
  20. after which you will be prompted for an update to 1.1.0 for the desktop developer, grab it if you intend to write anything for windows or linux, else, ignore it.
  21. now restart to make sure all settings changes have taken, remember to skip mounting the two bind mounts on startup
  22. sudo mount -a
  23. cd ~/android/environment/system/Titanium\ Developer-1.2.2/
  24. sudo ./Titanium\ Developer

Congratulations, you are now setup to work projects! I recommend leaving the snapshots for a bit, just in case you have issues. And of course, TAKE A NEW SNAPSHOT NOW!!! the last thing you want to do is screw something up at this point and have to go back… Also, since we have our dev env setup on a share from your local system, you can revert to this point at any time and still be able to pick right back up (I have not tested this yet!!).

I want to thank anyone who takes the time to read this, especially if you leave me comments, or tell me where I screwed up! It would be nice if someone comments about the app they create using this setup even!

  1. part one
  2. part two
  3. part three

Part Three – Configuring Ubuntu to use your newly installed Java JRE and SDK
There are a lot of technical steps in this part, and I figured them out mostly through heavy internet searching, piecing together information from other blogs, and trial and error. The main issues were caused by every site expecting you to already have some key components installed before trying to get this working. So when I tried to follow their guides they never worked. That is why we are here now, using a fresh and clean Ubuntu installation.

updated for Java 7 on February 8th 2012

  1. cd /opt/java && sudo ln -s /opt/java/jdk1.7.0_02 /opt/java/jdk-linked && sudo ln -s /opt/java/jdk1.7.0_02/jre /opt/java/jre-linked – this moves back to the /opt/java directory and creates a link to the jdk folder that we can use to reference to later, that way if we ever install a newer version of java all you have to do is remove the links and create new ones, not have to go through this whole process again! you can test by typing cd jdk-linked && ls – and you will see the contents of /opt/java/jdk1.7.0_02 (don’t forget you can use [tab])
  2. sudo update-alternatives –install “/usr/bin/java” java “/opt/java/jre-linked/bin/java” 10 && sudo update-alternatives –set java /opt/java/jre-linked/bin/java – this updates Ubuntu so it can find your new jre and makes it the default jre to be used by the system (again future proofed because we used the linked location)
    • if you want to, we can setup java for Firefox too
    • mkdir ~/.mozilla/plugins/ && ln -s /opt/java/jre-linked/lib/i386/libnpjp2.so ~/.mozilla/plugins
  3. cd && vi .profile
    • [ctrl+f]
    • [o]
    • EXPORT JAVA_HOME=/opt/java/jdk-linked
    • [enter]
    • EXPORT PATH=$PATH:$JAVA_HOME:$JAVA_HOME/bin
    • [esc]
    • :wq!
  4. now we need to repeat the next set of instruction with the following items placed in [java] (everytime you see [java] put one of the following until you have done these steps for each of the following), I have noted after each one if you need a jre or jdk, or both lines for it, if both, replace the 10 with a 5 on the jdk (this will add both the jre and the jdk alternatives to the list making the jre ones the default). Or, just use this script. (remember to look at the script first to make sure it does what I said, and to set it as executable! cat java-update|more && chmod +x java-update then execute it with sudo ./java-update)
    • java – jre/jdk
    • jar – jdk
    • jarsigner – jdk
    • javac – jdk
    • javadoc – jdk
    • javah – jdk
    • native2ascii – jdk
    • rmic – jdk
    • rmid – jre/jdk
    • rmiregistry – jre/jdk
    • serialver – jdk
    1. sudo update-alternatives –install “/usr/bin/[java]” [java] “/opt/java/jre-linked/bin/[java]” 10
    2. sudo update-alternatives –set [java] /opt/java/jre-linked/bin/[java]
  5. mkdir ~/source-build && cd ~/source-build && sudo apt-get install debhelper gcj-4.4-base gcj-jdk m4 debiandoc-sgml python-docutils cdbs – moving on, we need to install some things before the adding Titanium to the system, this group (plus their dependencies, you don’t want to know what I went through to get this list exactly correct, it took a couple of months the first time I worked on getting this installed) takes up 823MB and took me 16 minutes to download and 2.5 minutes to install. as an fyi, I figured these out by not having them installed the first time around and spent weeks trying to figure each part out, because these files are not what causes the failed instal, linux will pull the dependencies for you when you install something, but there are dependencies of dependencies of dependencies… and somewhere down that line linux fails to grab the final set! So you need to install them in this order, I then spent another week or 2 finding out that those in particular have to be installed before the next set or the next set fails to install!
  6. sudo rm /var/lib/apt/lists/* && sudo apt-get update – this will resolve an issue with the sources of the next step
  7. sudo apt-get install llvm-gcc-4.5 && sudo apt-get build-dep llvm-gcc-4.5 && sudo apt-get -b source python-defaults ruby-defaults && sudo apt-get update && sudo apt-get dselect-upgrade && sudo apt-get autoremove – this set downloads the source files for each of these and builds them specifically for your system and then cleans itself up, this did prompt me for 62.5MB of additional storage space and the build process took about 20 to 45 seconds on my machine.
  8. sudo apt-get install ispell – I have found a few other things that are necessary for titanium to work
  9. restart your development VM
  10. mount your shared drives and take a new snapshot after the system comes back up, called pre Android SDK, and comments “OS, java jre&jdk, and compilers installed”

maybe you don’t really need all of this, but I don’t want to find out while I am writing my Android app that I missed a step, as then you won’t be able to re-use the snapshots in case of an emergency (also called a mistake!). One other note, if you noticed I made a new directory and used it for the source builds, this is because at least the python source build requires several chown commands to run and if you try to execute them on a VM share mount it will fail and you cannot complete the build. Congratulations! I know this was a tough part to do, and I’ll have to check it over sometime in the future to recreate the entire process step by step and make sure it all works again (never know where there might be a typo!). Next time we meet it will be to install the Android SDK and Titanium. After that we will build a short crappy Android app to test everything and then make an .iso Live CD of the whole VM! The final file was pretty big, I’m not sure if a Live DVD would cover it all! I’ll test this idea and add it to the final post if it works. I will be heading out of town for a couple of days so don’t expect anything before monday!

  1. part one
  2. part two
  3. part four

again, after I finish this series up, I’ll add in resource links

Part Two – installing the Java SDK
updated February 8th 2012

Let just get right into it! open up your terminal session and lets continue!

  1. mkdir -p ~/android/environment/system – this will make both the environment and system folders with one command (I love -p!)
  2. sudo mount -a && cd ~/Downloads && ls – make sure everything that should be there is actually there
  3. wget http://download.oracle.com/otn-pub/java/jdk/7u2-b13/jdk-7u2-linux-i586.tar.gz – 32-bit Linux java SDK (includes the SE/JRE version and bypasses clicking the I agree button to their terms…)
  4. sudo mkdir /opt/java && sudo tar xvfz jdk-7u2-linux-x64.tar.gz -C /opt/java/
    – remember to use [tab] after typing jdk so you can use this even if the version gets updated
  5. sudo apt-get install galternatives
  6. sudo rm /opt/java/*.bin – this will remove almost 200MB from your VM HDD
  7. and restart the VM again
  8. after the VM comes back up mount your shares again and take a second snapshot, we’ll name this one Java jre & jdk installed, in the comments note that you have also added galternatives

We will finish up part two here, the next section is where a little mistake will have you reverting to this last snapshot, so you will be happy we made it (I did not make the second snapshot the first time through and while all the way at the end of part three I had to revert back to the end of part one and redo this section again).

  1. part one
  2. part three
  3. part four
Tagged with:
 

As a follow-up to my most popular post ever, installing KUbuntu 10.04 32-bit on VirtualBox and Appcelerator’s Titanium Mobile Developer, I am going to do another version for Ubuntu 10.10 32-bit running on VMware workstation 7.1.3. the installation process is mostly the same on VirtualBox, you will just have to follow a different method for setting up shared folders (you can use my previous post for that). Several things have changed in the last year and I haven’t done 10 minutes of development work, not to mention I am not even sure where the files for the 10.04 VM are! (update, I found them, but they failed to boot, might be the 600 freaking virtualbox updates since then!!) This has taken me 6 days to write up, I’m almost, but not quite done, AND it is close to 3000 words at this point, so I am going to post it in three four parts, so in any case let’s get started.

**anything in bold is either a heading or a command for you to type into a terminal window! (heading should also be underlined)

Part one – setting up Ubuntu 10.10 32-bit
(this is hoping you already have VMware workstation installed on your system, as I am not going to go through that process again! it was a nightmare and took weeks to get going on my current system. As background I am running Ubuntu (not KUbuntu like last time) 10.10 x64 as my host machine, and Ubuntu 10.10 32-bit as the guest. I am installing all of the development files on the VM, because the first time I tried setting Appcelerator’s Titanium on my host machine, I had to format and reinstall the OS, now I have learned the power of home virtualization and run almost everything through it instead of on my actual desktop. The most important thing I have learned is only assign 1 cpu core to any VM until you find it runs at 100% when you perform tasks within it, then increase the number of cores by 1, the second most important thing I have learned using virtual machines is to never install a 64-bit OS, things are just easier to do with a 32-bit OS. (currently the only computer in my house running windows is my work laptop and I’d change that if I didn’t think it would get me fired!)

  1. have a working operating system
  2. install VMware workstation
  3. download ubuntu 10.10 32-bit and use the automatically install VM guest tools options to simplify
  4. I recommend naming the vm something useful, like android-dev, or titanium-mobile
  5. then set the host name the same
  6. make the Virtual HDD at least 20GB (I made mine 38GB and we shall see if that is satisfactory over time…)
  7. after testing with the kitchen sink I have not seen the RAM usage go over 450MB, so let’s assign 768MB of ram at this time
  8. go ahead and set 1 CPU with 2 cores, as having the Android Emulator running will peg 1 core at 100% all the time
  9. follow-up by setting the account password the same as the VM name, so if you don’t use it for 6 months after setting it up, you’ll still be able to log in
  10. VMware VM settings

  11. next you need to setup shared folders in the VM, this is where we will store all of your work (on the host machine, incase something happens to the vm, you can always just wipe it and build another without losing your dev files.
    1. use the VMware workstation pull-down menu VM –> settings
    2. go to the options tab
    3. click shared folders
    4. select enabled
    5. add
    6. you should put what ever location you save your downloads to here, so you can get files from your host, then open them in the VM, I named this one “downloads”
    7. add a second shared folder, this one is where you want to keep your development environment, in case you need to reinstall Titanium on another machine later, I named this one “projects”

    VMware VM shared folders

  12. log into the new Ubuntu VM and let’s change some settings
    1. (you might not have to do this, but I did) go to the System pull-down menu –> preferences –> monitors and change the resolution to something more appealing than 800×600, make sure it is at least 1280×900 or you won’t be able to create a UVGA854 display android VM (even that might not be enough, but it is just enough for a WXVGA800 AVD)
    2. click make default, enter your password, then close all of those windows
    3. go to the Applications pull-down menu –> accessories –> terminal
    4. sudo apt-get update |sudo apt-get install dpkg dpkg-dev |sudo apt-get dselect-upgrade
    5. now, while that runs, let’s do some other things, go to the System pull-down menu –> preferences –> screen saver
    6. uncheck Activate screensaver when computer is idle and uncheck lock screen when screensaver is active
    7. click power management at the bottom and set display to never
    8. click make default, enter your password, then close all of those windows
    9. go to the system pull-down menu –> administration –> login screen and click “unlock” enter your password, and set it to log in automatically, then close all of those windows
    10. in the top right hand corner of the VM desktop click the power button (should be red) and select Restart to complete Update
  13. now open up your terminal again (if you closed it)
    • sudo apt-get autoremove
  14. the bad news is that you have to reinstall VMware tools, because you now have a new kernel
    1. go to the VMware pull-down menu VM –> reinstall VMware tools
    2. click ok on the popup
    3. the CD should auto-mount and open in a new window
      1. if not go to the Ubuntu Guest pull-down menu Places –>Computer
      2. on the left column go to File System –> /mnt –> open the VMware guest additions
      3. double click on the tar.gz file
      4. right click the folder vmware-tools-distrib
      5. select extract to…
      6. Put it in your downloads folder
      7. when it finishes, close all of these windows and go back to your terminal window
    4. navigate in the terminal to the vmware tools folder cd~/Downloads/vmware-tools-distrib
    5. sudo ./vmware-install.pl
    6. type yes to over-write the current installation
    7. press enter 10 times (when prompted!) to select the default installation locations (you will notice the script builds the tools from the source, which is nice), when it finishes, move on to the next step
    8. sudo vi /etc/fstab
      1. [Ctrl+f] – this should move the cursor to the last line
      2. o – this should insert a blank line at the end of the file and begin editing mode, copy and paste the following section and edit to fit the names you used or an alternate location if you don’t like mine.

      3. /mnt/hgfs/downloads /home/sdk/Downloads none bind,rw,user,auto,exec 0 0
        /mnt/hgfs/projects /home/sdk/android none bind,rw,user,auto,exec 0 0

      4. [Esc]
      5. : wq!
      6. [enter] – this will (in order) exit edit mode, save and quit the vi editor
      7. mkdir ~/android – you have to have an existing directory or the mount will fail!
    9. go to the power button in the top left corner of the guest screen (notice that it is grey this time, not red as there is not an update restart required)

      **note – it would appear that the vmware guest tools do not install and mount the shares before the mounting process for the OS (which makes sense if you think about it), this means every time you restart this VM you will have to type “s” twice to skip the failed mounting of these two bind mounts. an inconvenience, but remembering to type sudo mount -a is a lot easier than almost anything else you could do as an alternative, only because mount requires super user rights and during the login process you cannot respond to a prompt for your password.

  15. goto the VMware workstation pull-down menu VM –> Snapshot –>Take Snapshot
  16. change the snapshot name to: pre-java install
  17. put the description as: OS installed, configured, updated, restarted, VMware tools reinstalled for new kernel, restarted again. ready for Java SDK installation
  18. click ok to start the snapshot

Ok, this is the end of part one, here we have installed our Ubuntu 10.10 32-bit OS, updated it and created a snapshot so we have a quick easy back-out in case anything screws up during the java setup (this has happened to me more than once in the past!). Before continuing on, go to your home folder and make sure the 2 shared folders show up where you put them! else this next part might not be very pretty for you… :)

  1. part two
  2. part three
  3. part four
14 visitors online now
3 guests, 11 bots, 0 members
Max visitors today: 22 at 12:58 pm PST
This month: 26 at 02-09-2012 11:53 am PST
This year: 29 at 01-11-2012 02:49 pm PST
All time: 1100 at 08-08-2011 08:11 pm PDT
View in: Mobile | Standard