|
|
|||
I keep getting java.lang.SecurityException and emulator crashes (Android)
This is a simple program. I programed in Java and had never had this problem. The program has a couple of ImageButtons, EditText, and TextView elements. Design is in xml.files. When I ran the program with just EditView elements it worked fine. When I added the ImageButtons and the listeners, I have not been able to run it and the emulator crashes before the view comes up. Here is the log cat file. It may be a permissions issue, but I have no idea which permission to grant the program. I have been working on this for a week and a half and I am ready to pull my hair out. Please help. I can include any files you need. I have included the .java file. I am using eclipse with android SDK and ADT
07-09 01:51:22.193: ERROR/vold(27): Error opening switch name path '/sys/class/switch/test' (No such file or directory) 07-09 01:51:22.193: ERROR/vold(27): Error bootstrapping switch '/sys/class/switch/test' (No such file or directory) 07-09 01:51:22.193: ERROR/vold(27): Error opening switch name path '/sys/class/switch/test2' (No such file or directory) 07-09 01:51:22.193: ERROR/vold(27): Error bootstrapping switch '/sys/class/switch/test2' (No such file or directory) 07-09 01:51:46.002: ERROR/BatteryService(61): usbOnlinePath not found 07-09 01:51:46.012: ERROR/BatteryService(61): batteryVoltagePath not found 07-09 01:51:46.012: ERROR/BatteryService(61): batteryTemperaturePath not found 07-09 01:51:46.133: ERROR/SurfaceFlinger(61): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake 07-09 01:51:55.693: ERROR/EventHub(61): could not get driver version for /dev/input/mouse0, Not a typewriter 07-09 01:51:55.693: ERROR/EventHub(61): could not get driver version for /dev/input/mice, Not a typewriter 07-09 01:51:56.153: ERROR/System(61): Failure starting core service 07-09 01:51:56.153: ERROR/System(61): java.lang.SecurityException 07-09 01:51:56.153: ERROR/System(61): at android.os.BinderProxy.transact(NativeMethod) 07-09 01:51:56.153: ERROR/System(61): at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146) 07-09 01:51:56.153: ERROR/System(61): at android.os.ServiceManager.addService(ServiceManager.java:72) 07-09 01:51:56.153: ERROR/System(61): at com.android.server.ServerThread.run(SystemServer.java:176) 07-09 01:51:56.213: ERROR/AndroidRuntime(61): Crash logging skipped, no checkin service 07-09 01:52:16.998: ERROR/MediaPlayerService(31): Couldn't open fd for content://settings/system/notification_sound 07-09 01:52:17.018: ERROR/MediaPlayer(61): Unable to to create media player 07-09 01:52:20.619: ERROR/ActivityThread(105): Failed to find provider info for android.server.checkin 07-09 01:52:26.009: ERROR/ActivityThread(105): Failed to find provider info for android.server.checkin 07-09 01:52:26.619: ERROR/ActivityThread(105): Failed to find provider info for android.server.checkin 07-09 01:52:47.619: ERROR/AndroidRuntime(124): ERROR: thread attach failed 07-09 01:52:54.771: ERROR/AndroidRuntime(216): ERROR: thread attach failed 4 Replies
When i read "...and the emulator crashes before the view comes up." I initially thought you meant the app crashes in the emulator before any view appears, but, based on the log messages, it looks as if something is wrong with the emulator. It does not appear to be a permissions issue.
Try this: Configure a new AVD using the AVD and SDK Manager. Launch the emulator (not your app, just start the emulator), making sure it works before running or debugging your app. See if you get a different result. I can't think of why your emulator setup should suddenly fail that way, but it does not look like your app could cause those errors. If the above suggestion does not work, check your SDK installation: Make sure Eclipse, the SDK, and the JDK are all 64-bit compatible versions if your OS is 64 bit, for example, and double check all other aspects of your SDK installation.
Comment by
Jamie M
: Jul 14 2010 07:05 PM
I really hope you can help me. I have reinstalled everything. Let me explain exactly what happens and see if that helps. I have no errors in my code, in other words nothing is flagged and compiles fine. The emulator boots up and shows the screen that has the unlock and sound slides on the screen. Once that screen is showing for a few seconds, there is a flash of a "force close" window, but it is too fast to read. I am left with the lock and sound screen. I slide the unlock bar across and a Sorry my program has stopped unexpectedly and I am forced to hit force close. If there are any files you would like to see, let me know and I can upload them. I included the manifest.xml in case there is a problem there. I cut and pasted the java file.
package org.chrome9.GolfCalc; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.EditText; import android.widget.ImageButton; import android.widget.TextView; public class launchCalculator extends Activity { // Variables in the application int n=1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ImageButton btnCalc = (ImageButton)findViewById(R.id.btnCalc); btnCalc.setOnClickListener(new OnClickListener (){ @Override public void onClick(View v) { // TODO Auto-generated method stub }}); ImageButton btnNext=(ImageButton)findViewById(R.id.btnNext); btnNext.setOnClickListener(new OnClickListener (){ @Override public void onClick(View v) { // TODO Auto-generated method stub }}); ImageButton btnBack=(ImageButton)findViewById(R.id.btnBack); btnBack.setOnClickListener(new OnClickListener (){ @Override public void onClick(View v) { // TODO Auto-generated method stub }}); ImageButton btnReset=(ImageButton)findViewById(R.id.btnReset); btnReset.setOnClickListener(new OnClickListener (){ @Override public void onClick(View v) { // TODO Auto-generated method stub }}); ImageButton btnCourseHandicap=(ImageButton)findViewById(R.id.btnCourseHandicap); btnCourseHandicap.setOnClickListener(new OnClickListener (){ @Override public void onClick(View v) { // TODO Auto-generated method stub }});; TextView txtHeader = (TextView) findViewById(R.id.txtHeader); txtHeader.setText("Score: " + n); EditText txtEditScore = (EditText)findViewById(R.id.txtEditScore); txtEditScore.requestFocus(); txtEditScore.setText("0"); EditText txtEditRating = (EditText) findViewById(R.id.txtEditRating); txtEditRating.setText("0"); EditText txtEditSlope = (EditText) findViewById(R.id.txtEditSlope); txtEditSlope.setText("0"); } } Thank you in advance Attached File(s)
Based on your more-recent description, I think you will find that your application throws an unhandled exception.
Set a breakpoint at the call to setContentView(R.layout.main) and run the app under the debugger, using the "Debug as..." command to start it. Use the "step over" commend in the debugger to step through your application's code. When you encounter and unhandled exception, the debugger will display information about the exception. If it isn't obvious from looking at the statement that caused the exception, inspect the exception object using the debugger. Android exceptions often have descriptions that are very useful for diagnosing problems.
Comment by
Jamie M
: Jul 18 2010 12:10 AM
As I debugged, I found the following errors:
this ActivityThread (id=830066433136) activity launchCalculator (id=830066456616) aInfo ActivityInfo (id=830066437616) component ComponentName (id=830066437144) r ActivityThread$ActivityRecord (id=830066438872) customIntent null e ClassCastException (id=830066517112) cause ClassCastException (id=830066517112) cause ClassCastException (id=830066517112) detailMessage "android.widget.Button" (id=830066517144) count 21 hashCode 1583615229 offset 0 value (id=830066517176) stackState (id=830066517240) stackTrace null detailMessage "android.widget.Button" (id=830066517144) count 21 hashCode 1583615229 offset 0 value (id=830066517176) stackState (id=830066517240) stackTrace null ALSO java.lang.RuntimeException: Unable to start activity ComponentInfo{org.chrome9.GolfCalc/org.chrome9.GolfCalc.launchCalculator}: java.lang.ClassCastException: android.widget.Button and java.lang.reflect.InvocationTargetException Apparently there is a problem with the android.widget.button. I cannot figure out what the issue is. I do not even use android.widget.button. I import android.widget.ImageButton. I know I am missing something simple. *****Never mind, I found it. I had used a <Button> tag instead of <ImageButton> in one of the spots in my main.xml file. With the correction, it works fine. Thank you for your help. I learned a lot about debugging through this process. |
|||
|