Developing Applications with Android API Level 7

This section describes why 'AboutAndroid' fails to run on Android 2.2.2 phone. The getObbDir() method is supported only on Android 2.3.4 (API Level 10) and higher. To run on 99% of existing Android devices, you need to develop the application with API Level 7.

In this tutorial, I want to try to figure out why "AboutAndroid" crashes on my LG-P925g phone.

1. Go to the LG-P925g phone and run "AboutAndroid" again. You will get the application crash error message again.

2. Go to the Windows computer and check the log buffer using the "adb -d logcat" command:

C:\herong\AboutAndroid>\local\android-sdk-windows\platform-tools\adb
   -d logcat AndroidRuntime:E *:S

--------- beginning of /dev/log/main
--------- beginning of /dev/log/system
E/AndroidRuntime( 8681): FATAL EXCEPTION: main
E/AndroidRuntime( 8681): java.lang.NoSuchMethodError: 
                         com.herongyang.AboutAndroid.getObbDir
E/AndroidRuntime( 8681):  at com.herongyang.AboutAndroid.onCreate
                          (AboutAndroid.java:61)
E/AndroidRuntime( 8681):  at android.app.Instrumentation.callActiv...
E/AndroidRuntime( 8681):  at android.app.ActivityThread.performLau...
E/AndroidRuntime( 8681):  at android.app.ActivityThread.handleLaun...
E/AndroidRuntime( 8681):  at android.app.ActivityThread.access$230...
E/AndroidRuntime( 8681):  at android.app.ActivityThread$H.handleMe...
E/AndroidRuntime( 8681):  at android.os.Handler.dispatchMessage(Ha...
E/AndroidRuntime( 8681):  at android.os.Looper.loop(Looper.java:12...
E/AndroidRuntime( 8681):  at android.app.ActivityThread.main(Activ...
E/AndroidRuntime( 8681):  at java.lang.reflect.Method.invokeNative...
E/AndroidRuntime( 8681):  at java.lang.reflect.Method.invoke(Metho...
E/AndroidRuntime( 8681):  at com.android.internal.os.ZygoteInit$Me...
E/AndroidRuntime( 8681):  at com.android.internal.os.ZygoteInit.ma...
E/AndroidRuntime( 8681):  at dalvik.system.NativeStart.main(Native...

The log buffer does have some details about the crash: getObbDir() method is not supported by my LG-P925g phone.

This is because my LG-P925g phone is running Android 2.2.2, which has the API level of 8, while the getObbDir() method was introduced since API Level 11.

Now we learned that when develop a new Android application, we can not go with the classes and methods offered in the latest version of the API, if you want your application to run on existing Android devices currently used by millions of users.

Here is diagram of usage share of the different Android versions as of 2 April 2012 from wikipedia.com:

Usage Share of Android Versions as of 2012
Usage Share of Android Versions as of 2012

So if you want your new application to cover 99% of existing Android devices, you need to develop it with Android API level 7, which should run on Android 2.1 and higher devices. Do not use anything higher than Android API level 7.

I think you know how to modify "AboutAndroid" Java code to make it work on LG-P925g. Try it yourself.

Last update: 2012.

Table of Contents

 About This Book

 Installing JDK 1.8 on Windows System

 Installation of Android SDK R24 and Emulator

 Installing Apache Ant 1.9 on Windows System

 Developing First Android Application - HelloAndroid

 Android Application Package (APK) Files

 Android Debug Bridge (adb) Tool

 Android File Systems

 Android 4.0.3 File Systems

 AboutAndroid - Application to Retrieve System Information

 android.app.Activity Class and Activity Lifecycle

 View Objects and Layout Resource Files

 Using "adb logcat" Command for Debugging

 Build Process and Package File Content

 Building Your Own Web Browser

 Android Command Line Shell

 Samsung Galaxy Tab 3 Mini Tablet

 USB Debugging Applications on Samsung Tablet

 Android Tablet - LG-V905R

 USB Debugging Applications on LG-V905R Tablet

 Android Phone - LG-P925g

USB Debugging Applications on LG-P925g Phone

 Installing LG USB Device Driver on Windows

 Viewing LG Android USB Device in Control Panel

 Turning on USB Debugging on LG-P925g

 Viewing USB Debugging Devices in Control Panel

 Running "adb" on LG-P925g USB Debugging Interface

 Installing Application to Phone using "ant installd" Command

 Installing Application to Phone using "adb -d install" Command

 "adb -d install" Command Options

 Installing "AboutAndroid" to LG-P925g Phone

Developing Applications with Android API Level 7

 Outdated Tutorials

 References

 PDF Printing Version