Monday, January 7, 2013

Connecting Android to Apache on localhost

Sometimes the requirements given to client/s are a bit odd especially when you are working as a freelance.  In my previous android projects, apps that requires internet permissions is as easy as what on the android documentation says.  Recently, I've got a project that uses internet to fetch updates.  The resources that I have are a site and a mysql database.  Now, I have to setup this site into local and run some tests on localhost.  In order for you to connect your android device to access localhost, make sure your laptop and android device are on the same wifi network.  You need to get the ip address of your localhost.  To do this, execute this command:

$ ifconfig

This is a utility used by system administrators to display and analyze network interface parameters.  Result should display like the image below.

The ip address of the laptop is at the wlan0 which is  We may have different results depending on how many devices connected on wifi.  You may have something like 192.168.1.xx.  So on your test device, try changing the localhost to your ip address.

WebView webview = (WebView) findViewById(;
webview.setWebViewClient(new WebViewClient());

Thanks to this post at StackOverflow.

Thursday, January 3, 2013

Android Terminal Emulator Crashes on cm-10.1 [Part 1]

After I installed the cm-10.1 on LGE p970 and tested it, it was pretty fast and smooth except for 2 things.

  1. Android Terminal Emulator (ATE) app crashes on launch.
  2. People app couldn't find vcard during import even though it exists on the root directory of the sdcard.
The ATE is a very important tool (at least for me).  I always use this during development and hacking.  I prefer  to work and debug things wirelessly.  So this article is about tweaking android and stuffs that I wanted them to behave.

The Cause.  Before I flashed cm-10.1, I remembered updating the ATE from Google Play.  During testing cm-10.1, the app crashes.  Finding the cause was easy.  First, I checked the stack trace.  Here's what the stack trace said.

Serioulsy?  This wasn't clear to me at all.  Second, I went to Google Play and found out that ATE is an open source project hosted at github.  From there, I browsed the issues before doing stupid things (i.e. asking solutions from developers or posting it in the issue tracker) and found this interesting issue (same as mine).

issue #133 Force close on start (UnsatisfiedLinkError)

It says,
I think if you install the apk into /system/app, the library loader needs the native library in /system/lib. (If you install to /data via the normal route, the package manager unpacks any native libraries in the package to /data/data/, and the library loader will look there also.)Basically, either extract from the apk and install it to /system/lib, or install the package normally and let the package manager deal with this for you. This isn't a bug in ATE.
By reading this comment, everything is now clear.

So What Happened? By reading the first line of the stack trace,

java.lang.UnsatisfiedLinkError: Couldn't load jackpal-androidterm4 from loader dalvik.system.PathClassLoader[dexPath=/system/app/Term.apk,libraryPath=/data/data/jackpal-androidterm/lib]: findLibrary returned null

the system couldn't load a shared library in

in the library path,


this makes sense because after I update ATE, its path changed to /data/data/jackal.androidterm.  Since cm-10, ATE is preconfigured in the rom so path should be


as mentioned in the comment, extract from the apk and push it into /system/lib.  I haven't try this yet so I'll post it on the next series.