smorgasbork

 
  • Increase font size
  • Default font size
  • Decrease font size

Compiling titanium mobile SDK from scratch

E-mail Print

I recently needed to compile Titanium Mobile SDK from scratch. I was a little intimidated by the process. And as I feared, I ran into some nasty issues.

My build environment is a MacBook Pro running OS X 10.9.5. I've been using Titanium Studio on this machine for a while, building Titanium apps and even doing a little native module development with it.

I installed all the prerequisites as documented here. But I still ran into this nasty error:

BUILD FAILED
/Users/priebe/Desktop/titanium_mobile/android/build/common.xml:616: The following error occurred while executing this line:
/Users/priebe/Desktop/titanium_mobile/android/build/common.xml:649: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre"

My .bashrc file looked like this:

export ANDROID_NDK=~/android-ndk-r9d
export ANDROID_SDK=/Applications/adt-bundle-mac-x86_64-20140702/sdk
export ANDROID_HOME=/Applications/adt-bundle-mac-x86_64-20140702/sdk
export ANDROID_PLATFORM=$ANDROID_SDK/platforms/android-21
export GOOGLE_APIS=$ANDROID_SDK/add-ons/addon-google_apis-google-21
export JAVA_HOME=`/usr/libexec/java_home -v '1.8*'`
export ANT_HOME=/usr/local/ant

Despite the fact that my JAVA_HOME environment variable resolved to this:

/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home

for some reason, some part of the build process was trying to tack on an extra "/jre" to the end of my JAVA_HOME. I scoured the Interwebs for a cause and a solution. I found some articles that got close to the problem, but didn't quite capture my problem, were Windows-specific, or the author didn't fully explain the workaround.

I'm still a bit murky on why this happens, but somewhere inside of ant, it is using a different mechanism to define its java.home variable. It doesn't get it directly from the JAVA_HOME environment variable. A lot of online posts refer to ways to change that within Eclipse. But I'm using the command line, so I didn't think those approaches would apply in my case. It certainly doesn't help that the error message implies that ant is using the JAVA_HOME environment variable.

My fix was to edit titanium_mobile/android/build/common.xml. For every <javac> element in the XML file, I added these properties:

fork="yes"
executable="/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/javac"

So for example:

<javac destdir="@{build.dir}"
    fork="yes"
    executable="/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/javac"
    includes="@{includes}"
    excludes="@{excludes}"
    target="1.6"
    source="1.6"
    debug="@{debug}"
    includeantruntime="false">

This got me past the "Unable to find a javac compiler" error. Woohoo! Now I'm on easy street, right? Wrong. Turns out that the Titanium Mobile SDK won't compile with JDK 1.8 yet. You'll get an error like this:

 /Users/priebe/Desktop/titanium_mobile/android/titanium/src/java/org/appcelerator/titanium/TiBlob.java:561: error: cannot access BinaryEncoder
    [javac]   return new String(Base64.encodeBase64(getBytes()));
    [javac]                           ^
    [javac]   class file for org.apache.commons.codec.BinaryEncoder not found

Turns out there's even a JIRA issue for this problem.

OK, so I downloaded and installed JDK 1.7, made some adjustments to my .bashrc and to common.xml. My .bashrc became this:

export ANDROID_NDK=~/android-ndk-r9d
export ANDROID_SDK=/Applications/adt-bundle-mac-x86_64-20140702/sdk
export ANDROID_HOME=/Applications/adt-bundle-mac-x86_64-20140702/sdk
export ANDROID_PLATFORM=$ANDROID_SDK/platforms/android-21
export GOOGLE_APIS=$ANDROID_SDK/add-ons/addon-google_apis-google-21
export JAVA_HOME=`/usr/libexec/java_home -v '1.7*'`
export ANT_HOME=/usr/local/ant

My common.xml <javac> directives looked like this:

<javac destdir="@{build.dir}"
    fork="yes"
    executable="/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/javac"
    includes="@{includes}"
    excludes="@{excludes}"
    target="1.6"
    source="1.6"
    debug="@{debug}"
    includeantruntime="false">

Much to my amazement and delight, the SDK compiled completely. There was a little weirdness at the end of the output:

Packaging version (4.1.0) complete
scons: done building targets.
Exception TypeError: "'NoneType' object is not callable" in > ignored

but the ZIP archive with the SDK was created, and other than the last line, the output indicated success. BTW -- on this machine, it took about 2 minutes to compile the whole thing, which I thought was surprisingly fast.

 

Titanium Mobile Gotchas (volume 2)

E-mail Print

Here is another compilation of weird Titanium gotchas that we encountered while building a fairly large-scale (100+ JS modules, 40K lines of JS) app with Titanium Mobile SDK 3.4.x.

Read more...
 

Google Play Services SDK Version History

E-mail Print

A couple of times, I've found it necessary to know what version of google play services I'm dealing with. For example, when I was using a number of Titanium modules that were dependent on google play services, I had version conflicts. But Google Play Services versioning is a nightmare. This article tries to make sense of it all.

Read more...
 

Building a custom CentOS 7 kickstart disc, part 1

E-mail Print

Note: this series of articles applies to CentOS 7; for CentOS 6, see this series.

CentOS (and of course, it's upstream distro, Red Hat Enterprise Linux) has an extremely powerful, but somewhat poorly documented, tool for rapidly deploying machines and managing their configuration: kickstart. Kickstart lets you build a custom installation that can run hands-free. So not only is the installation quick and easy for you, you can be confident that your machines are configured exactly the way you want them to be.

Read more...
 

OpenELEC 4 upgrade woes

E-mail Print

I was very excited to see that the OpenELEC team had released version 4.0, based on XBMC Gotham. I read a lot before attempting an upgrade, and I still had huge problems with the upgrade from OpenELEC 3.2.

Read more...
 

Warning: Illegal string offset 'active' in /home/priebe/smorgasbork.com/templates/ja_purity/html/pagination.php on line 129

Warning: Illegal string offset 'active' in /home/priebe/smorgasbork.com/templates/ja_purity/html/pagination.php on line 135

Warning: Illegal string offset 'active' in /home/priebe/smorgasbork.com/templates/ja_purity/html/pagination.php on line 129

Warning: Illegal string offset 'active' in /home/priebe/smorgasbork.com/templates/ja_purity/html/pagination.php on line 135

Warning: Illegal string offset 'active' in /home/priebe/smorgasbork.com/templates/ja_purity/html/pagination.php on line 129

Warning: Illegal string offset 'active' in /home/priebe/smorgasbork.com/templates/ja_purity/html/pagination.php on line 135

Warning: Illegal string offset 'active' in /home/priebe/smorgasbork.com/templates/ja_purity/html/pagination.php on line 129

Warning: Illegal string offset 'active' in /home/priebe/smorgasbork.com/templates/ja_purity/html/pagination.php on line 135

Warning: Illegal string offset 'active' in /home/priebe/smorgasbork.com/templates/ja_purity/html/pagination.php on line 129

Warning: Illegal string offset 'active' in /home/priebe/smorgasbork.com/templates/ja_purity/html/pagination.php on line 135

Warning: Illegal string offset 'active' in /home/priebe/smorgasbork.com/templates/ja_purity/html/pagination.php on line 129

Warning: Illegal string offset 'active' in /home/priebe/smorgasbork.com/templates/ja_purity/html/pagination.php on line 135

Warning: Illegal string offset 'active' in /home/priebe/smorgasbork.com/templates/ja_purity/html/pagination.php on line 129

Warning: Illegal string offset 'active' in /home/priebe/smorgasbork.com/templates/ja_purity/html/pagination.php on line 135

Warning: Illegal string offset 'active' in /home/priebe/smorgasbork.com/templates/ja_purity/html/pagination.php on line 129

Warning: Illegal string offset 'active' in /home/priebe/smorgasbork.com/templates/ja_purity/html/pagination.php on line 135

Warning: Illegal string offset 'active' in /home/priebe/smorgasbork.com/templates/ja_purity/html/pagination.php on line 129

Warning: Illegal string offset 'active' in /home/priebe/smorgasbork.com/templates/ja_purity/html/pagination.php on line 135

Warning: Illegal string offset 'active' in /home/priebe/smorgasbork.com/templates/ja_purity/html/pagination.php on line 129

Warning: Illegal string offset 'active' in /home/priebe/smorgasbork.com/templates/ja_purity/html/pagination.php on line 135
  • «
  •  Start 
  •  Prev 
  •  1 
  •  2 
  •  3 
  •  4 
  •  5 
  •  6 
  •  7 
  •  8 
  •  9 
  •  10 
  •  Next 
  •  End 
  • »

A List Apart


Warning: Creating default object from empty value in /home/priebe/smorgasbork.com/modules/mod_feed/helper.php on line 46

Planet CentOS


Warning: Creating default object from empty value in /home/priebe/smorgasbork.com/modules/mod_feed/helper.php on line 46