NPE when drawing TabWidget in android (only on HTC Magic?) - android

I've received report from the user of an app I've written that he gets FC whenever starting a certain activity. I have not been able to reproduce the issue on the emulator or on my HTC Hero (running 1.5), but this user running HTC Magic (with 1.6) is facing this error every time.
What bothers me is that no single step in the stacktrace actually includes any code in my app (com.filmtipset)
01-07 00:10:26.773 I/ActivityManager( 141): Starting activity: Intent { cmp=com.filmtipset/.ViewMovie (has extras) }
01-07 00:10:27.023 D/AndroidRuntime( 2402): Shutting down VM
01-07 00:10:27.023 W/dalvikvm( 2402): threadid=3: thread exiting with uncaught exception (group=0x4001e170)
01-07 00:10:27.023 E/AndroidRuntime( 2402): Uncaught handler: thread main exiting due to uncaught exception
01-07 00:10:27.083 E/AndroidRuntime( 2402): java.lang.NullPointerException
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.widget.TabWidget.dispatchDraw(TabWidget.java:173)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.view.ViewGroup.drawChild(ViewGroup.java:1529)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.view.ViewGroup.drawChild(ViewGroup.java:1529)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.view.ViewGroup.drawChild(ViewGroup.java:1529)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.view.View.draw(View.java:6552)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.widget.FrameLayout.draw(FrameLayout.java:352)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.view.View.draw(View.java:6552)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.widget.FrameLayout.draw(FrameLayout.java:352)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1883)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.view.ViewRoot.draw(ViewRoot.java:1332)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.view.ViewRoot.performTraversals(ViewRoot.java:1097)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.view.ViewRoot.handleMessage(ViewRoot.java:1613)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.os.Handler.dispatchMessage(Handler.java:99)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.os.Looper.loop(Looper.java:123)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.app.ActivityThread.main(ActivityThread.java:4320)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at java.lang.reflect.Method.invokeNative(Native Method)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at java.lang.reflect.Method.invoke(Method.java:521)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at dalvik.system.NativeStart.main(Native Method)
Full dump here if I've missed anything of interest
I'm guessing, then, that there might be something wrong with my layout. It's quite verbose, so I'm posting it here, rather than pasting the whole thing on SO.
There is a tabwidget, where one tab is connected to the scrollview, svFilmInfo, and one to the linear layout llComments.
The tab host is populated as such:
Drawable commentSelector = getResources().getDrawable(R.drawable.tabcomment);
Drawable infoSelector = getResources().getDrawable(R.drawable.tabinfo);
mTabHost = getTabHost();
mTabHost.getTabWidget().setBackgroundColor(Color.BLACK);
mTabHost.addTab(mTabHost.newTabSpec("tabInfo").setIndicator("Filminfo", infoSelector).setContent(R.id.svFilmInfo));
mTabHost.addTab(mTabHost.newTabSpec("tabInfo").setIndicator("Kommentarer", commentSelector).setContent(R.id.llComments));
Since I cannot reproduce the error myself, and since I cannot find any mention in the stack trace of what might be causing the error, I don't quite know where to start troubleshooting this.
I'd appreciate any pointers.

I run into stack traces like that when people have a TabHost in their layout but do not add TabSpecs to it. You show the code where you add tabs -- are you sure that is being called in all circumstances?

I got the same error in my application, but only on Android 1.6 and higher - it worked on 1.5.
The reason: initial application Activity extended TabActivity but layout XML with TabHost widget was not loaded via setContentView() in onCreate() scope (it was scheduled to load via Runnable a little bit later).
Then first try to actually draw such not-fully-processed TabActivity on screen caused crash with NullPointerException at android.widget.TabWidget.dispatchDraw(TabWidget.java:173)
You have to load XML or instantiate TabHost and fill with newTabSpecs programatically before onCreate ends.

Related

Android + Corona SDK: Couldn't Load Lua

Yes, I know this question is similar to this, but it never got answered and I don't like resurrecting old threads (from July '13).
I just began testing my game on a real device (yay!), and though it works perfectly on the Corona Simulator, every time I open it on the actual device and now the emulator, I get "Sorry! The application SampleApp (process com.foo.bar.SampleApp) has stopped unexpectedly. Please try again." I opened adb logcat and find that I'm getting this error:
I/ActivityThread( 1264): Pub com.foo.bar.SampleApp.files: com.ansca.corona.storage.FileContentProvider
W/dalvikvm( 1264): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcom/ansca/corona/JavaToNativeShim;
W/dalvikvm( 1264): Exception Ljava/lang/ExceptionInInitializerError; thrown while initializing Lcom/ansca/corona/CoronaEnvironment;
D/AndroidRuntime( 1264): Shutting down VM
W/dalvikvm( 1264): threadid=1: thread exiting with uncaught exception (group=0x40020560)
E/AndroidRuntime( 1264): FATAL EXCEPTION: main
E/AndroidRuntime( 1264): java.lang.ExceptionInInitializerError
E/AndroidRuntime( 1264): at com.ansca.corona.CoronaView.deleteTempDirectory(CoronaView.java:141)
E/AndroidRuntime( 1264): at com.ansca.corona.CoronaActivity.onCreate(CoronaActivity.java:101)
E/AndroidRuntime( 1264): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime( 1264): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1618)
E/AndroidRuntime( 1264): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1670)
E/AndroidRuntime( 1264): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
E/AndroidRuntime( 1264): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
E/AndroidRuntime( 1264): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 1264): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime( 1264): at android.app.ActivityThread.main(ActivityThread.java:3695)
E/AndroidRuntime( 1264): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 1264): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 1264): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
E/AndroidRuntime( 1264): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
E/AndroidRuntime( 1264): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 1264): Caused by: java.lang.ExceptionInInitializerError
E/AndroidRuntime( 1264): at com.ansca.corona.CoronaEnvironment.setLuaErrorHandler(CoronaEnvironment.java:379)
E/AndroidRuntime( 1264): at com.ansca.corona.CoronaEnvironment.<clinit>(CoronaEnvironment.java:41)
E/AndroidRuntime( 1264): ... 15 more
E/AndroidRuntime( 1264): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load lua: findLibrary returned null
E/AndroidRuntime( 1264): at java.lang.Runtime.loadLibrary(Runtime.java:429)
E/AndroidRuntime( 1264): at java.lang.System.loadLibrary(System.java:554)
E/AndroidRuntime( 1264): at com.ansca.corona.JavaToNativeShim.<clinit>(JavaToNativeShim.java:118)
E/AndroidRuntime( 1264): ... 17 more
W/ActivityManager( 146): Force finishing activity com.foo.bar.SampleApp/com.ansca.corona.CoronaActivity
Of course, the real process name isn't com.foo.bar.SampleApp, but it's the same thing.
I have an old Android, so that may be the issue, but I sure hope not. I'm on a Huawei-U8652, Android version 2.3.5. I also built a Corona sample code app, and it did the same thing with the same error.
The error is that Lua can't be found, that's pretty extreme. Works from Corona Sim, but not on real device, or in Eclipse-based emulator. Until you can get it to work on the real device, there is no point in using the emulator, it's just too much of an unknown wrt Corona. Try this:
verify examples that come with Corona work on your device
if they do, start adding parts of your main.lua in one of those examples; maybe at some point the error will happen again, allowing you to identify a specific lib call that corrupts memory and sends everything wally
start adding other parts of your app (if you import modules during startup), until you see the error again

Google Drive SDK application to upload file

I am trying to use the Google Drive SDK to upload files, but I am getting a pop up saying unfortunately your application has stopped. This is due to a NoClassDefFoundError. I also made sure to include the play services jar and check it in the order and export tab as well.
This is the excpetion:
E/AndroidRuntime( 4906): java.lang.NoClassDefFoundError: com.google.android.gms.common.AccountPicker
E/AndroidRuntime( 4906): at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential.
newChooseAccountIntent(GoogleAccountCredential.java:253)
E/AndroidRuntime( 4906): at com.example.informationretreival.MainActivity.onCreate(MainActivity.java:42)
E/AndroidRuntime( 4906): at android.app.Activity.performCreate(Activity.java:5104)
E/AndroidRuntime( 4906): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
E/AndroidRuntime( 4906): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2147)
E/AndroidRuntime( 4906): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
E/AndroidRuntime( 4906): at android.app.ActivityThread.access$600(ActivityThread.java:144)
E/AndroidRuntime( 4906): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
E/AndroidRuntime( 4906): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 4906): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 4906): at android.app.ActivityThread.main(ActivityThread.java:5074)
E/AndroidRuntime( 4906): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 4906): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 4906): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
E/AndroidRuntime( 4906): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
E/AndroidRuntime( 4906): at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager( 771): Force finishing activity com.example.informationretreival/.MainActivity
I am following the quickstart on the developer website I have literally just copied the code. I would expect the quickstart example to work. Someone please point me in the right direction.
In your Android application configuration page, select Google APIs (Google Inc.) (API 17) for Compile with. Also, it would work more stable on real phone than virtual device since virtual device doesn't have play store.

Navit Excepition:java.lang.ExceptionInInitializerError

While running the Navit code for car navigation, I am getting the following exception, i thought that navit library is not available. please any one help me.
E/AndroidRuntime( 365): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime( 365): java.lang.ExceptionInInitializerError
E/AndroidRuntime( 365): at java.lang.Class.newInstanceImpl(Native Method)
E/AndroidRuntime( 365): at java.lang.Class.newInstance(Class.java:1472)
E/AndroidRuntime( 365): at android.app.Instrumentation.newActivity(Instrumentation.java:1097)
E/AndroidRuntime( 365): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2316)
E/AndroidRuntime( 365): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
E/AndroidRuntime( 365): at android.app.ActivityThread.access$2100(ActivityThread.java:116)
E/AndroidRuntime( 365): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
E/AndroidRuntime( 365): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 365): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 365): at android.app.ActivityThread.main(ActivityThread.java:4203)
E/AndroidRuntime( 365): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 365): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 365): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
E/AndroidRuntime( 365): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
E/AndroidRuntime( 365): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 365): Caused by: java.lang.UnsatisfiedLinkError: Library navit not found
E/AndroidRuntime( 365): at java.lang.Runtime.loadLibrary(Runtime.java:489)
E/AndroidRuntime( 365): at java.lang.System.loadLibrary(System.java:557)
i downloaded the Navit code from , navit svn.ttps://navit.svn.sourceforge.net/svnroot/navit/trunk/navit But unable to run the code.
i want to run this code in Eclipse for Android Project.
You need to download Android NDK
Create standalong tools for your ARCH
Cross compile to ARM
Run make apkg
This error is due to missing libnavit.so.
Put libnavit.so it in /data/local
Change System.LoadLibrary to System.Load("/data/local/libnavit.so");
make apkg
Install
This exception should go away.

GLSurfaceView.onDetachedFromWindow

I have a little issues with an GLSurfaceView, when I start my Activity I make the GLSurfaceView invisible with this line of code:
glSurface.setVisibility(View.INVISIBLE);
During this time I start an AsyncTask which downloads an Image from network, at this time, if I press the back button I meet this Exception:
java.lang.NullPointerException
E/AndroidRuntime( 1847): at android.opengl.GLSurfaceView.onDetachedFromWindow(GLSurfaceView.java:530)
E/AndroidRuntime( 1847): at android.view.View.dispatchDetachedFromWindow(View.java:6033)
E/AndroidRuntime( 1847): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1156)
E/AndroidRuntime( 1847): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1156)
E/AndroidRuntime( 1847): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1156)
E/AndroidRuntime( 1847): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1156)
E/AndroidRuntime( 1847): at android.view.ViewRoot.dispatchDetachedFromWindow(ViewRoot.java:1630)
E/AndroidRuntime( 1847): at android.view.ViewRoot.doDie(ViewRoot.java:2671)
E/AndroidRuntime( 1847): at android.view.ViewRoot.die(ViewRoot.java:2641)
E/AndroidRuntime( 1847): at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:218)
E/AndroidRuntime( 1847): at android.view.Window$LocalWindowManager.removeViewImmediate(Window.java:436)
E/AndroidRuntime( 1847): at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3684)
E/AndroidRuntime( 1847): at android.app.ActivityThread.access$2900(ActivityThread.java:125)
E/AndroidRuntime( 1847): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
E/AndroidRuntime( 1847): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 1847): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 1847): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime( 1847): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 1847): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 1847): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime( 1847): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidR
What's wrong?
It could be that you haven't set the renderer.
From the android reference:
onDetachedFromWindow ()... Must not be called before a renderer has been set.
So, if you set the renderer (even if you aren't rendering anything yet), this might avoid the issue.

Unable to fill List Layout in App

I'm attempting to write my first android app and am having a little
problem with filling a List Layout from a DB.
The project itself is here:
http://code.google.com/p/biofuelsfinder/
However the specific code I'm having the problem with is here:
public void fillData(String fueltype){
ArrayList<String> items = new ArrayList<String>();
Cursor retailers = biofuelsDB.getRetailers("b5");
/*while(!retailers.isAfterLast()){
retailers.moveToNext();
try{
items.add(retailers.getString(retailers.getColumnIndex("name")));
} catch(IllegalStateException e){
String msg = e.getMessage();
}
//items.add(user.lastName);
//items.add(user.country);
}*/
items.add("Blah1");
items.add("Blah2");
items.add("Blah3");
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.retailers_row, items);
/*setListAdapter(adapter);*/
}
The two portions commented out, if run cause and illegalStateException
error which then aborts the code.
If anyone could have a look and let me know what I'm going wrong that
would be most appreciated.
Below is the stacktrace
W/dalvikvm( 208): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
E/AndroidRuntime( 208): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime( 208): java.lang.IllegalStateException: Could not execute method of the activity
E/AndroidRuntime( 208): at android.view.View$1.onClick(View.java:2031)
E/AndroidRuntime( 208): at android.view.View.performClick(View.java:2364)
E/AndroidRuntime( 208): at android.view.View.onTouchEvent(View.java:4179)
E/AndroidRuntime( 208): at android.widget.TextView.onTouchEvent(TextView.java:6532)
E/AndroidRuntime( 208): at android.view.View.dispatchTouchEvent(View.java:3709)
E/AndroidRuntime( 208): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
E/AndroidRuntime( 208): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
E/AndroidRuntime( 208): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
E/AndroidRuntime( 208): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
E/AndroidRuntime( 208): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
E/AndroidRuntime( 208): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
E/AndroidRuntime( 208): at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
E/AndroidRuntime( 208): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
E/AndroidRuntime( 208): at android.view.ViewRoot.handleMessage(ViewRoot.java:1690)
E/AndroidRuntime( 208): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 208): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 208): at android.app.ActivityThread.main(ActivityThread.java:4310)
E/AndroidRuntime( 208): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 208): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 208): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime( 208): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
E/AndroidRuntime( 208): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 208): Caused by: java.lang.reflect.InvocationTargetException
E/AndroidRuntime( 208): at com.biofuelsfinder.biofuelsfinder.buttonClickHandler(biofuelsfinder.java:37)
E/AndroidRuntime( 208): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 208): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 208): at android.view.View$1.onClick(View.java:2026)
E/AndroidRuntime( 208): ... 21 more
E/AndroidRuntime( 208): Caused by: java.lang.NullPointerException
E/AndroidRuntime( 208): at com.biofuelsfinder.RetailerList.fillData(RetailerList.java:34)
E/AndroidRuntime( 208): ... 25 more
Thanks
I think your 'biofuelsDB' is still null!
Add this line after Arrayadapter:
ListView lv;
lv.setAdapter(items);

Categories

Resources