Discussion Forums  >  Crashes, Memory Warnings

Replies: 9    Views: 116

Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
03/21/12 11:42 AM (12 years ago)

Force close - Android BTv1.5 - Very little hair left...

I've got a very basic Android BTv1.5 project running in the emulator. A splash screen. A menu list with one item. The one item is a Custom url. I click on the menu item, the url loads up, works fine for between 10 and 20 seconds (I do not click on anything in the web page), then the app force closes. The error is: E/AndroidRuntime(412): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.btpgstest/com.btpgstest.BT_screen_menuList}: java.lang.NullPointerException I sort of understand the reasons why this might happen when I'm on the menulist screen, but I've got no idea why this would be happening when I'm on the custom URL screen. (the url is an index.html in the assets folder). Does anyone have any ideas?
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
03/21/12 11:53 AM (12 years ago)
There are some good clues here and it does look like you have it "understood" as good as anyone. When Android transitions from one activity to the next, the previous activity is still "running" in the background in most cases. You can't really control how or when Android terminates the previous activity. So, the Menu List is behind the scenes still doing it's thing while you interact with the Web View holding index.html This means something about the way the menu list is behaving is for sure causing the crash. Null Pointer Exception is helpful but doesn't tell us much. I wonder what it's looking for that doesn't exist? Hmm... Does the menu list have any background artwork loading? Could it be that it's not fully loaded, then you leave it to the next screen, then it crashes because it was trying to do something it couldn't - like paint an image on the screen when the screen is in the background. Dunno really, thinking out loud here.. What happens if you load the menu, then sit for a very long time, like :60 seconds or something just to be sure. Does the app still crash? If not, does it crash :20 seconds after you leave the FULLY loaded menu (after waiting awhile). Not sure what's happening but we'll need to figure out what the menu is looking for that doesn't exist. And, when it's looking for it.
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
03/21/12 12:07 PM (12 years ago)
Thanks for replying David. There's a header image and background image in the menu screen, but not in the global theme. From watching the app and following logcat, it looks like they fully load up. I did actually leave it on the menu screen like you suggest, while I grabbed a coffee. It was probably over 10 minutes and the app didn't force close, but it did after about 20 seconds of viewing the webpage. I've just noticed, immediately before the force close, there's a logcat entry: W/ZZ(541): BT_screen_menuList:onCreate, don't know if that's relevent, as I assume it should have already been loaded up previously?
 
Fred@mySkylla com
Android Fan
Profile
Posts: 5259
Reg: Oct 03, 2011
location unknow...
62,560
like
03/21/12 12:08 PM (12 years ago)
Two issues: BTv1.5 Android Splash screen has issues that have not been resolved. You'll have problems if you're using that screen. What device are you getting the force close on? Android os? 2.3.4? Fred
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
03/21/12 12:15 PM (12 years ago)
Thanks Fred. I'm testing on the emulator. I can't find any issues in logcat with the splashscreen, it looks to be performing correctly. The issue seems to be revolving around the menulist screen, but I'll remove the splashscreen and see what happens.
 
Fred@mySkylla com
Android Fan
Profile
Posts: 5259
Reg: Oct 03, 2011
location unknow...
62,560
like
03/21/12 12:19 PM (12 years ago)
Since you're using the VD I would suspect an error in an image or screen nickname. Look for spaces and non alpha characters. Fred
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
03/21/12 12:39 PM (12 years ago)
The LogCat messages are designed to show you when each method is called. In the case of the BT_screen_menuList:onCreate message, it's showing that when this event occurs. I would expect it to run "onCreate" once, when the menu list is rendered. I would not expect it to run again just before the webView crashes. It sounds like the menu list isn't causing the crash, if you sat around a bit and it didn't crash before moving to the web view and it didn't crash - cool. Could there be something in the WebView that's causing the issue? The sample index.html shouldn't be causing this so probably not. Looking back at your post and the error: BT_screen_menuList "unable to create activity" hmm, seems odd. This activity is created when the menu loads, not when the webView loads. Could there be another tab (tabbed app) that is also loading a menu as it's home screen? If so, then you'll be onCreate'ing multiple activities, one for each tab.
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
03/21/12 04:33 PM (12 years ago)
I've found what's causing the problem, but not how or why. Back to the drawingboard I guess. The html references two .js files in the assets folder. Everything is running ok until BOTH the files are added. I tried referencing them externally, but get the same problem. I think the main problem causer is jquery. Damn annoying as it's a really cool integration that I'd like to share. Even more annoying, it works fine with ph*neg*p.
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
03/21/12 04:35 PM (12 years ago)
Ah, good news. So the you must have added the jQuery reference to the sample file. This could make sense. I would think that jQuery would be pretty bullet proof in mobile. Not sure really. I wonder if there is an adjustment that's needed in the WebView properties in the activity? In other words, there are tons of little things that can be allowed / not allowed through with java that affect the webView's behavior. Allowing jScript, preventing jScript etc, etc. JQuery forum maybe?
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
03/21/12 04:40 PM (12 years ago)
I have to say, I haven't looked at the sample file, just stripped it out and added my own stuff. Perhaps a revisit is needed, and a study of the webview.java. I'll update the thread if I find a solution!
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.