aspose file tools*
The moose likes Android and the fly likes android uncaught handler: thread main exiting due to uncaught exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "android uncaught handler: thread main exiting due to uncaught exception" Watch "android uncaught handler: thread main exiting due to uncaught exception" New topic
Author

android uncaught handler: thread main exiting due to uncaught exception

Ammon Miranda
Greenhorn

Joined: Aug 09, 2010
Posts: 4
cant figure out where error is coming from and how to fix it. I am new to android programming(not java) so sorry for possible slowness :P Here is files I think you need to see

Main.java



main.xml


Manifest.xml



LogCat



Project Specs:
Build Target: Android 2.1 update-1


sorry for commented out code in there but debugging like crazy. I am new to debugging on here. I am running this in an emulator through Eclipse. thanks in advance
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

please provide your string.xml file.


Life is easy because we write the source code.....
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9321
    
  17

The error clearly states that there is no layout_width attribute defined one of the elements in main.xml, check RelativeLayout in main.xml. Also in the future please post only the relevant parts of the logcat, I've removed the unnecessary portion for you this time...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Ammon Miranda
Greenhorn

Joined: Aug 09, 2010
Posts: 4
Thanks guys and sorry bout that here is some update code that I have done and I seem to be having some issues with thread permissions/management. I added the Looper.prepare() which an error told me was missing and that I needed in order to create a handler within the new thread. The layout_width I noticed just after I posted the code, but thanks. I posted [relevant] LogCat. Anyway, here is the updated code:

Main.java



main.xml


strings.xml



AndroidManifest.xml



LogCat




Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9321
    
  17

There is too much code to process, all the layout info is not needed again as now the problem is not related to it. You must have some idea where the exception is getting raised. Please post only the part of the code that is causing the problem. You have a better chance of getting a response in that case...
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

Requires ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION permission


You must have to add following permission in your AndroidManifest.xml file.

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />


Ammon Miranda
Greenhorn

Joined: Aug 09, 2010
Posts: 4
ok sorry bout all that. I just included in case needed. Basically, as you see, there are no problems in the strings.xml or mail.xml. The error seems to be coming from permissions not being allowed to certain threads. I have created only two threads, the main UI thread and an additional getLocThread to process getting locations. You can view the latest posts before for all details but here is the simplification and I will give the gist first:

I created the main UI (obv auto) I then created a Runnable called updateLocTV to send with the handler mCallback back to the main thread from the getLocThread used to run all of this OUTSIDE of UI thread. I am getting errors involving permissions that you can see inside of LogCat. I just noticed [in LogCat] that the Package Manager doesnt recognize permissions I added into the manifest. I added a few more permission just now during debugging and none of them are recognized.

The error arises when the locationManager requests updates
lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
on line 138 below in Main.java

Now, here is the code for:

Main.java
AndroidManifest.xml
LogCat <-- all errors and warnings displayed, nothing else

not sure if you need any other quick reference but, here are a few
Reference:

onCreate -------------------- line 61
final Handler mCallback --- line 76
Runnable updateLocTV ---- line 78
getLocThread --------------- line 118
where error occurs --------- line 138


Main.java



AndroidManifest.xml



LogCat



Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
Check your spelling:

# 08-10 18:26:23.916: WARN/PackageManager(52): Unknown permission andoid.permission.INTERNET in package com.sunynpcs.GPSex2
# 08-10 18:26:23.938: WARN/PackageManager(52): Unknown permission andoid.permission.SEND_SMS in package com.sunynpcs.GPSex2
# 08-10 18:26:23.948: WARN/PackageManager(52): Unknown permission andoid.permission.ACCESS_FINE_LOCATION in package com.sunynpcs.GPSex2
# 08-10 18:26:23.967: WARN/PackageManager(52): Unknown permission andoid.permission.ACCESS_COARSE_LOCATION in package com.sunynpcs.GPSex2
# 08-10 18:26:23.977: WARN/PackageManager(52): Unknown permission andoid.permission.ACCESS_NETWORK_STATE in package com.sunynpcs.GPSex2
Ammon Miranda
Greenhorn

Joined: Aug 09, 2010
Posts: 4
Lester you are my hero!! It now works!! well, at least it ready for my further development. Thanks SOO much. I dont know if I will need all the permissions I added to get around the security issue but I will leave them anyway for now. Thanks again. I am not going to worry yet about the other warnings more posts and new threads coming I am sure :-/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: android uncaught handler: thread main exiting due to uncaught exception