I have been slowing learning and building my first android app. I'm VERY new to java but have already done a couple of projects in C#, VB.NET (back in the day), Objective-C (have 6 apps in the store) and Fortran (waaaaaaaaaaaaaaaaaaaay back in the day ;)
So I just received from overseas a htc legend (I'm not in the US), which i bought in order to have a decent mid-level device for development (it's running non-rooted adnroid 2.1)
The application I have been developing is target level 4 (android 1.6). It uses a 5 Mb sqlite3 database with a .mp3 extension to avoid compression within the apk and proper copying from assets to system folder.
It all works fine on the emulator, and on the device I see that the file size of the app after copying the database matches exactly what I see on the emulator.
now, on my main activity with a list view and a spinner, I bind some data through two array adapters. when running on the device all does smoothly. but when trying to run on the device this part of the code:
public class mainAct extends Activity implements OnItemSelectedListener, TextWatcher, OnItemClickListener
{
/** members */
//private EditText searchtext;
private ListView designations;
private ArrayAdapter<String> adapterShapes;
private ArrayAdapter<String> adapterTypes;
private Spinner types;
.
.
.
public void onCreate(Bundle savedInstanceState)
{
.
.
.
// DESIGNATIONS
//
adapterShapes = new ArrayAdapter<String>(this,R.layout.list_item,shapes); // custom TextView Adapter
designations=(ListView)findViewById(R.id.designations);
Log.e("MAIN.ACCT", "ok to 172");
designations.setAdapter(adapterShapes);
Log.e("MAIN.ACCT", "ok to 174");
designations.setOnItemClickListener(this);
// TYPES
//
adapterTypes=new ArrayAdapter<String>(this,R.layout.spinner_item,DT.get().typesInLibrary);
types=(Spinner)findViewById(R.id.types);
types.setAdapter(adapterTypes);
types.setOnItemSelectedListener(this);
.
.
.
}
}
Both designations.setAdapter(adapterShapes);
& types.setAdapter(adapterTypes);
give me a Null Pointer exception.
I'm using eclipse under mac, the LogCat window throws:
06-25 18:41:37.842: ERROR/AndroidRuntime(9523): Uncaught handler: thread main exiting due to uncaught exception
06-25 18:41:37.891: ERROR/AndroidRuntime(9523): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.davidhomes.steel/com.davidhomes.steel.mainAct}: java.lang.NullPointerException
06-25 18:41:37.891: ERROR/AndroidRuntime(9523): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2596)
06-25 18:41:37.891: ERROR/AndroidRuntime(9523): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2621)
06-25 18:41:37.891: ERROR/AndroidRuntime(9523): at android.app.ActivityThread.access$2200(ActivityThread.java:126)
06-25 18:41:37.891: ERROR/AndroidRuntime(9523): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1932)
06-25 18:41:37.891: ERROR/AndroidRuntime(9523): at android.os.Handler.dispatchMessage(Handler.java:99)
06-25 18:41:37.891: ERROR/AndroidRuntime(9523): at android.os.Looper.loop(Looper.java:123)
06-25 18:41:37.891: ERROR/AndroidRuntime(9523): at android.app.ActivityThread.main(ActivityThread.java:4595)
06-25 18:41:37.891: ERROR/AndroidRuntime(9523): at java.lang.reflect.Method.invokeNative(Native Method)
06-25 18:41:37.891: ERROR/AndroidRuntime(9523): at java.lang.reflect.Method.invoke(Method.java:521)
06-25 18:41:37.891: ERROR/AndroidRuntime(9523): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
06-25 18:41:37.891: ERROR/AndroidRuntime(9523): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
06-25 18:41:37.891: ERROR/AndroidRuntime(9523): at dalvik.system.NativeStart.main(Native Method)
06-25 18:41:37.891: ERROR/AndroidRuntime(9523): Caused by: java.lang.NullPointerException
-------------------------------------------------------------- 06-25 18:41:37.891: ERROR/AndroidRuntime(9523): at com.davidhomes.steel.mainAct.onCreate(mainAct.java:183)--------------------------------------------------------------
06-25 18:41:37.891: ERROR/AndroidRuntime(9523): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-25 18:41:37.891: ERROR/AndroidRuntime(9523): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2544)
06-25 18:41:37.891: ERROR/AndroidRuntime(9523): ... 11 more
06-25 18:46:38.252: ERROR/ActivityManager(99): fail to set top app changed!
Line 183 is the first setAdapter call (designations.setAdapter(adapterShapes);), when I comment it out the second setAdapter is the one breaking code
I'm a little lost here, the adapters show the proper number of items on the log window when running from the simulator and the device.
I admit to being a noob to both java and android, so any help is highly appreciated.
regards
david