Jason’s Ranting & Raving

Those who don’t read have no advantage over those who can’t.

Archive for September, 2010

Programming: Android emulator launch from eclipse

Posted by jaystile on September 27, 2010

There are some quirks launching the Android emulator from Eclipse. Work has started on my first Android application, and I kept running into ‘oddness’. I would see errors like this:

06:57:10,094 INFO  [main] Main  - launchFile: C:\workspace\android\.metadata\.plugins\org.eclipse.wst.xsl.jaxp.launching\launch\launch.xml
06:57:10,141 FATAL [main] Main  - No embedded stylesheet instruction for file: file:/C:/workspace/android/tmpproj/res/layout/main.xml
org.eclipse.wst.xsl.jaxp.debug.invoker.TransformationException: No embedded stylesheet instruction for file: file:/C:/workspace/android/tmpproj/res/layout/main.xml
	at org.eclipse.wst.xsl.jaxp.debug.invoker.internal.JAXPSAXProcessorInvoker.transform(JAXPSAXProcessorInvoker.java:225)
	at org.eclipse.wst.xsl.jaxp.debug.invoker.internal.JAXPSAXProcessorInvoker.transform(JAXPSAXProcessorInvoker.java:186)
	at org.eclipse.wst.xsl.jaxp.debug.invoker.internal.Main.main(Main.java:73)
Caused by: org.eclipse.wst.xsl.jaxp.debug.invoker.TransformationException: No embedded stylesheet instruction for file: file:/C:/workspace/android/tmpproj/res/layout/main.xml
	at org.eclipse.wst.xsl.jaxp.debug.invoker.internal.JAXPSAXProcessorInvoker.transform(JAXPSAXProcessorInvoker.java:214)
	... 2 more

Then a main.out.xml was getting created and it only happened sometimes. Those *.out files need to be removed. Confusion set in.

It turns out that I was clicking the ‘Run’ button while my main.xml file was selected. This makes eclipse try and do something other than launch my Android app. You need to actually select Run -> Run Configurations -> to get it to launch. 45 minutes of my life are gone!


Posted in Uncategorized | 1 Comment »

Programming: Android setup for Ubuntu

Posted by jaystile on September 27, 2010

Android Setup
I’ve been kicking the idea around of developing some Android applications. This blog post is about setting up that initial environment.

After a quick google search, I found the Android developer page. Downloaded the Linux (i386) SDK. I was thinking that I might want to develop on Windows, but I already had a VirtualBox running Ubuntu 10.04 with the Required Eclipse and JDK. I browsed the System Retirements page http://developer.android.com/sdk/requirements.html, and it looks the VM (Virtual Machine) will be just fine.

Java development downloads go to into the /opt directory on this linux VM. Softlinks are used to help maintain version of the software.

/opt/ant/latest → /opt/app/apache-ant-1.8.1
/opt/java/latest → /opt/java/jdk1.6.0_21
/opt/eclipse/latest →/opt/eclipse/eclipse-jee-helios

The ~/.bashrc file gets updated to add variables to these locations and then export the $PATH so you can execute them on the command line.

export PATH=$JAVA_HOME/bin:$ANT_HOME/bin:$PATH

Download the Android SDK

$ mkdir /opt/android/
$ wget http://dl.google.com/android/android-sdk_r07-linux_x86.tgz
$ tar zxvf android-sdk_r07-linux_x86.tgz
$ mv android-sdk-linux_x86 android-sdk-linux_x86-0.9.8 
$ ln -s android-sdk-linux_x86-0.9.8/ latest

ADT Plugin v 0.9.8
The Eclipse workspace has been setup to use /opt/workspace/android. Eclipse then needed to include the ADT plug-in . Add the site: https://dl-ssl.google.com/android/eclipse/ to Eclipse after selection Help → Install Software.

Install SDK Tools r7 into your SDK
The link describes adding new tools into your sdk http://developer.android.com/sdk/adding-components.html#UpdatingComponents .

Launch the android manager.

$ /opt/android/latest/tools/android

It looks like the Android SDK Tool revision 7 was already there! Moving on.
I got a pop-up from the Plug-in asking to enable statistics usage. But it was ‘unclickable’. So it’s just hanging out there now, so I’ll have to kill it from the command line. I could tell if it came from the Android manager or the ADT eclipse plugin.

First Project
Used Eclipse to try and create a new Android Project. This failed because an SDK was not defined.
Register SDK with Eclipse
Window → Preferences → Android
SDK Location: /opt/android/latest
Failed to get the adb version: Cannot run program “/opt/android/latest/tools/adb”: java.io.IOException:error=2, No such file or directory.
That is very odd. The file is navigable from the command line. However, when trying to execute it from the command line like ./adb, the bash: ./adb: No such file or directory error occurs.
Attempting to restart (and kill that pop-up that is still hanging around).

$ /opt/android/latest/tools/android

Install packages
Installed Packages → Android SDK Tools, revision 7. Clicked update all and selected all recommended downloads.
Then removed all obsolete packages.

Try Again – With Galileo
Downloaded Eclipse JEE Galileo, I heard rumor through the grapevine that ADT Plugin did not play nice with Helios.
This still did not resolve the original issue of the adb not working.

Add the site: https://dl-ssl.google.com/android/eclipse/ to Eclipse after selection Help → Install Software. In this instance, I made it to the license agreement. However, when selecting the radio, “I agree” and scrolling down to the bottom of the license window, the ‘Finish’ button was never enabled. Thank you Mylyn for having 9 things to agree to when all I’m trying to is NOT add your plug in. It is my professional opinion that Eclipse with JEE comes with way too many plug-ins that do not have value add. Eclipse is pretty stable, but the plug-in developers really need to get on the ball. I keep running into resource hogs or plug-ins that don’t do their job very well. Have you seen the GIT plug-in? It doesn’t even come close to mapping what you can do on the command line. Going to get Eclipse just for Java to minimize plug-ins to see if I can get this to install.

Try Again – With Galileo sans JEE garbage.
Installed the basic Eclipse IDE for Java Developers. There are noticably less plug-ins install that might collide. But Mylyn is still there. Let’s see how it goes. Oh look at that! It appears that I am in the same situation. Here are the list of things to agree to:

Android DDMS
Android Development Tools
Mylyn Bridge: Eclipse IDE
Mylyn Bridge: Java Development
Mylyn Bridge: Team Support
Mylyn Connector: Bugzilla
Mylyn Task List (Required)
Mylyn Task-Focused Interface (Recommended)
Mylyn WikiText

Let’s see if my outcome is any different this time. I’ll scroll to the bottom of each agree and check I accept. Wow! Different behavior! The ‘Finish’ button was able to be clicked. Joyous happy day.

Back on track – Setup the SDK
Window → Preferences → Android
SDK Location: /opt/android/latest

Configure the SDK
Eclipse → Window → Android SDK and AVD Manager
Something weird happened again.
After selecting the option above I received and error. [2010-09-17 06:12:09 – adb]Failed to get the adb version: Cannot run program “/opt/android/latest/tools/adb”: java.io.IOException: error=2, No such file or directory
After selecting it a second time, the application launched.
Android SDK and AVD Manager (ASAM) → Installed Packages → Update All…
Now ‘Delete…’ any obsolete packages.

I got another error saying that there are packages dependent on adb, but it isn’t running. I think the 0.9.8 SKD might be fubar. After more research, there is a problem with Ubuntu 64bit (which I’m running). It looks like some 32bit libraries need to be installed. There was nothing explicit on the Android SDK site, but after more searching I found references to the 32 bit libraries under an Ubuntu forum. Then I found a matching troubleshooting article on the SDK site.

$ sudo apt-get install ia32-libs
$ /opt/android/latest/tools/adb 

Yay! ADB now does something! That was the root of my problem. Now everything is right with the world. Two hours later my quest continues.

Ubuntu Linux 13.10 64-bit
The error ‘bash: ./adb: No such file or directory’ came back. But this time ‘install ia32-libs’ did not work. However, this seemed to do the trick:

$ sudo apt-get install libc6:i386 libstdc++6:i386

Hello World
Follow the instructions from the Android Site. http://developer.android.com/resources/tutorials/hello-world.html
After the errors before, getting the Hello, Android app running was a piece of cake. That emulator is pretty cool. Then I said, f@#$ it, and I set it up to run on my windows environment.

Posted in Programming | Tagged: , | 1 Comment »