• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

android uncaught handler: thread main exiting due to uncaught exception

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please provide your string.xml file.
 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Ammon Miranda
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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



 
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 :-/
 
reply
    Bookmark Topic Watch Topic
  • New Topic