Android Studio comedy of errors

My goal is to learn enough about Android programming to code an adapter or bridge of some sort that allows an Android program to make use of my Java-based audio mixer and audio tools. To that end, I decided to install Android Studio on my newly made PC. But it’s taken close to a month to get the software to work! Last night I was finally able to run parts I & II of the tutorials provided at the Android site: successfully emulating a Nexus 5 which ran an app that displays the text “Hello world!”.

The last time I wrote about this, on the Chit-Chat Monster, I was complaining about “configuration hell” and getting the Emulator to work at all. I found out many JGO’ers also found the software difficult to install and make use of alternatives. So, maybe, maybe not, some notes on what went wrong and how it was solved will be useful?

  1. I think the decision to use Android-Studio instead of the Eclipse plug-ins for Android development is okay. This seems like a good way to keep this work segregated. I found switching between Eclipse workspaces to be clumsy. Also, having all the Android stuff seemed like clutter when I was just trying to do pure Java dev. But maybe it is just a matter of preference.

  2. It makes a difference if you are using an Intel cpu vs AMD. I suspect that at Google, most Android development is done on Intel cpu’s. The main reason I came to this conclusion: the easiest to find instructions recommend installing an Intel-made and provided tool for vm acceleration, and I believe it only supports Intel cpu’s. It is certainly possible to run Android Studio on AMD with acceleration, but you will have to go online to find “how-to’s” on blogs and StackOverflow, rather than being within the safe bounds of “official” instruction pages. (See #8 below.)

I built my computer with an AMD setup. I don’t regret this, but I could see where someone who wanted to do Android dev and was making a decision as to the cpu for their system might be advised to prefer Intel.

  1. I decided to install on Linux. My understanding was that Android dev was originally done on Linux, and the instructions for how to build the vm acceleration on Linux were less scary than for Windows 8.1. I am admittedly over my head here and may have gotten the wrong impression, but it seemed to me that, on Windows 8.1, the work-around for acceleration for the emulator compromises some of the graphics pertaining to the new tablets oriented GUI. I could easily be wrong on this, though. The decision was made pretty far back and I have forgotten most of the details.

Of course, if you are new to Linux, factor in an additional learning curve!

I decided to go with the current Ubuntu, 14.04.

  1. Partitioning for dual booting is a bit tricky. I decided to follow a tutorial that recommended having two partitions where there might more usually be one: one for “/” and one for “/home”. It seems there might be performance benefits, but again, I am speculating beyond my competence level. This split led to some complications which I will get to, but so far I think it was an okay decision. The main thing: many of the blogs are becoming more and more dated. Be sure to check the date, and maybe guestimate on the high side–the older blogs have size recommendations that are clearly too small for the current generation of computers and software. I figure the trend for sizing the partitions for the swap and for the “/” (if you go that route) will be to always increase over time.

5) You won’t be able to use Ubuntu’s built in software tools for installing Java. Android Studio requires Java 7, and Ubuntu is only providing Java 6. I ended up installing Java 7 from Oracle, in /usr/lib and it went okay. But, I’ve been reading that this might not have been the ideal choice. There was an article on where to install in the Ubuntu help areas, and I can’t recall where it is at the moment. It does exist, and in my scanning of it I noted that there was another /usr folder that might have been better. At this point, as long as it works, I’m not going to revisit the issue.
EDIT: just took a second look at Ubuntu Software Center and did a search for Java. OpenJDK 7 was on the list. My mistake.

  1. The directions for installing Android Studio and the Android SDK confused me. If starting again, I would simply put both on $HOME, in separate file folders. I made the mistake of setting one up on /usr/lib and the other at $HOME. Then, when running Android Studio, I found I had to use “sudo” as part of the command. This led to problems.

a) Files were being built in file folders in /root, and this was cramping the “/” partition, leading to system warnings about lack of disk space. Some of the files built there were the result of updates or installs, especially via the SDK Manager.

b) The .ini files built by the AVD Manager were ending up in /root and not visible to Android Studio.

It seems “sudo” (I am new to Linux/Ubuntu) changes the value of $HOME and/or some other environment variables that are used by Android, and the various sub-systems aren’t in synch on this. All this grief can be avoided by just installing everything on $HOME and making sure there is no need to use sudo when launching the application. (I ended up moving the /usr/lib install to $HOME, and then going to /root to remove two Android directories that were built there. Mucking around with /root is generally not recommended as it is a good way to totally wipe out your OS. It seems I was careful enough, though, this time.)

  1. If you are running a 64-bit OS, you will have to load a program for running 32-bit mode. The first web blogs I found that identify this problem recommend the use of a program (ia32-libs) that was dropped after Ubuntu 12. It took more digging but eventually found the replacement packages.

8.) I think (am not entirely sure) that you have to install the vm acceleration software in order for the AVD Manager to work and to be able to run emulations. I installed KVM. The basic overview on configuring VM acceleration on Linux is at the following site:

http://developer.android.com/tools/devices/emulator.html

Details on installing KVM can be found here:
https://help.ubuntu.com/community/KVM/Installation

To be honest, I’m not entirely clear if the Nexus 5 emulation I ran on my first tutorial made use of the acceleration or not. I’m going to have to review the process I went through in the AVD manager, and see if I did the steps spelled out in the first link above (under the heading “Configuring VM Acceleration on Linux”). (Late middle-age memory issues, compounded with minimal understanding. I did this somewhat earlier in the process of steps and the emulator fails I thought I was thus correcting may have been more about not having the 32-bit code runner working.)


Am very much looking forward to getting back to programming, proper.

??? :stuck_out_tongue: ??? :stuck_out_tongue: ???

Hey Phil, having fun there?! ;D

Rather than tying yourself in knots over this, it’s worth looking to see if anyone has done the job for you (the latter looks like it might be better) -


If you’re new to Ubuntu and what you want isn’t in the official repositories, it’s worth checking out what PPA’s are available before going with manual install. There is also a PPA for Oracle Java, which will install it in the right place for you!

This statement is wrong, btw - Ubuntu has both Java 6 and Java 7 (OpenJDK, obviously!) available in the standard repositories.

@nsigma - Thanks for rubbing it in, after the fact. :wink:

I could have used this info earlier. I’m new enough with Ubuntu and Linux that the searches I did for installation help did not uncover this. I really wasn’t aware of or had grasped the PPA concept or how to search for them.

Here’s another fun one for naive Ubuntu users, a major “Doh!” moment for me. Le’t say you have an executable, and using the Terminal shell, you navigate to the file folder where the executable resides and type in it’s name. What happens: crickets, and a command not found message. But when you type ‘ls’ the command is clearly there in the file folder. SOLUTION: to execute the command, you have to prefix the file name with “./” .

I’m unclear if the PPA you linked installs the KVM or not.

It looks like this PPA-made Studio has to be run with sudo after all. Maybe it is okay that both the Android Studio and the Android SDK are in the /usr folder, and they will communicate with each other nicely that way. I’m guessing that there’s a lot going on in the /root directory as a consequence. As long as it works (most users say it does) then that’s all good. But for my dual partition setup of Ubuntu, it would have been an utter disaster. I made “/” only 15 GB, with the bulk of the remaining disk space (350+GB) going to $HOME. Putting Android in /usr would have cramped up the 15 GB pretty quickly. (So maybe what that indicates is that the advice to make a dual partition for Ubuntu was bad to begin with.)

As long as it’s working, I’m not going to go back and change anything. :stuck_out_tongue:

Well, live and learn. Life of a DIY’er–unless you write something that impresses someone so much that they decide they want to help out, you have to spend a disproportionate time in learning an endless number of technologies and mastering countless configuration issues. That is time that might otherwise be spent with the much more fun programming and experimenting. 8)

I also had some trouble installing Android Studio on my Windows Machine but when I did, the benefits definitely out weighed the problems. That being said, however, I still prefer eclipse when coding libgdx apps.

This is because by default the shell looks for the command in the PATH environment variable, you can add the current working directory to the PATH and it should work. For you the current working directory is not in the PATH variable so you need to use “./” to predicate the full location.