Skip to content
Jan 8 11

Google fixes a bug

by admin

As I reported, Google Analytics for Android would sometimes throw an SQLiteException.  Of course the big G was getting on-line flack over that and has now put out a new version of their JAR file.  Version 1.1 claims to fix this problem.  You can check it out at code.google.com/mobile/analytics/docs/android at the bottom of the page.

Jan 1 11

Can Google programmers code Android?

by admin

You would think if anyone would know how to write Android code it would be coders at Google.  Yet if you use the Google Analytics library available for Android, you might run into trouble.  Google Analytics is great to track usage of your Android application, but should Google Analytics ever cause your app to crash?

Google Analytics did cause one of my apps to crash and the stack trace looked like:

android.database.sqlite.SQLiteException: unable to open database file
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2787)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2803)
at android.app.ActivityThread.access$2300(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2136)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:144)
at android.app.ActivityThread.main(ActivityThread.java:4937)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.database.sqlite.SQLiteException: unable to open database file
at android.database.sqlite.SQLiteDatabase.dbopen(Native Method)
at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1899)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:881)
at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:168)
at com.google.android.apps.analytics.PersistentEventStore.getNumStoredEvents(Unknown Source)
at com.google.android.apps.analytics.PersistentEventStore.startNewVisit(Unknown Source)
at com.google.android.apps.analytics.GoogleAnalyticsTracker.start(Unknown Source)
at com.google.android.apps.analytics.GoogleAnalyticsTracker.start(Unknown Source)

So Google Analytics tried to use SQLite to open the database, but FAILED to catch an SQLiteException.  The fix was to wrap opening up Google Analytics into a try-catch block and catch that exception.  Here are the relevant code fragments to fix the crash by catching the exception Google Analytics failed to:


import com.google.android.apps.analytics.GoogleAnalyticsTracker;
GoogleAnalyticsTracker tracker = null;
try {
tracker = GoogleAnalyticsTracker.getInstance();
tracker.start("UA-123456-78", 20, this);
}
catch (android.database.sqlite.SQLiteException sqle)
{
Log.d(SUBSYSTEM_TAG, "Google Analytics SQLite exception: "+sqle);
tracker = null;
}
catch (Exception e)
{
Log.d(SUBSYSTEM_TAG, "Google Analytics exception: "+e);
tracker = null;
}
if (tracker != null)
tracker.trackEvent("Android", action, label, val);

The OnDestroy() method code looks like:

if (tracker != null) {
tracker.stop();
tracker = null;
}

Remember you have to catch these exceptions if you use Google Analytics in your Android app, otherwise one of your users may watch your app crash.  How do you think they’ll rate your app then?

Jun 8 10

Android App Store shortcomings

by admin

The Google Market has been the only game around for Android Apps, although that may be changing. Some of the Market’s shortcomings include:

  • No screenshots of your application.
  • 325 character limit on descriptions.
  • Google Checkout is the only payment option.
  • Apps are hard for users to find.
  • No way to download an application through the web via a web link.

Some improvements may be on the way, but these are gotchas for developers today.