如题 。
如果单单是按钮之类的组件的话就不会出现这种错误,
但是加了监听就出现了,为什么啊 异常信息我贴了给大家,
11-17 09:32:59.402: ERROR/Zygote(33): setreuid() failed. errno: 2
11-17 09:33:14.923: ERROR/Zygote(33): setreuid() failed. errno: 17
11-17 09:33:18.012: ERROR/BatteryService(69): usbOnlinePath not found
11-17 09:33:18.012: ERROR/BatteryService(69): batteryVoltagePath not found
11-17 09:33:18.022: ERROR/BatteryService(69): batteryTemperaturePath not found
11-17 09:33:18.092: ERROR/SurfaceFlinger(69): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake
11-17 09:33:29.351: ERROR/EventHub(69): could not get driver version for /dev/input/mouse0, Not a typewriter
11-17 09:33:29.351: ERROR/EventHub(69): could not get driver version for /dev/input/mice, Not a typewriter
11-17 09:33:29.772: ERROR/System(69): Failure starting core service
11-17 09:33:29.772: ERROR/System(69): java.lang.SecurityException
11-17 09:33:29.772: ERROR/System(69): at android.os.BinderProxy.transact(Native Method)
11-17 09:33:29.772: ERROR/System(69): at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146)
11-17 09:33:29.772: ERROR/System(69): at android.os.ServiceManager.addService(ServiceManager.java:72)
11-17 09:33:29.772: ERROR/System(69): at com.android.server.ServerThread.run(SystemServer.java:184)
11-17 09:33:32.382: ERROR/SoundPool(69): error loading /system/media/audio/ui/Effect_Tick.ogg
11-17 09:33:32.402: ERROR/SoundPool(69): error loading /system/media/audio/ui/KeypressStandard.ogg
11-17 09:33:32.431: ERROR/SoundPool(69): error loading /system/media/audio/ui/KeypressSpacebar.ogg
11-17 09:33:32.463: ERROR/SoundPool(69): error loading /system/media/audio/ui/KeypressDelete.ogg
11-17 09:33:32.483: ERROR/SoundPool(69): error loading /system/media/audio/ui/KeypressReturn.ogg
11-17 09:33:38.032: ERROR/ThrottleService(69): Could not open GPS configuration file /etc/gps.conf
11-17 09:33:39.711: ERROR/logwrapper(143): executing /system/bin/tc failed: No such file or directory
11-17 09:33:39.823: ERROR/logwrapper(146): executing /system/bin/tc failed: No such file or directory
11-17 09:33:39.982: ERROR/logwrapper(147): executing /system/bin/tc failed: No such file or directory
11-17 09:34:35.272: ERROR/AndroidRuntime(277): FATAL EXCEPTION: main
11-17 09:34:35.272: ERROR/AndroidRuntime(277): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.handerTest/com.handerTest.HanderActivity}: java.lang.ClassNotFoundException: com.handerTest.HanderActivity in loader dalvik.system.PathClassLoader[/data/app/com.handerTest-1.apk]
11-17 09:34:35.272: ERROR/AndroidRuntime(277): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
11-17 09:34:35.272: ERROR/AndroidRuntime(277): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
11-17 09:34:35.272: ERROR/AndroidRuntime(277): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
11-17 09:34:35.272: ERROR/AndroidRuntime(277): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
11-17 09:34:35.272: ERROR/AndroidRuntime(277): at android.os.Handler.dispatchMessage(Handler.java:99)
11-17 09:34:35.272: ERROR/AndroidRuntime(277): at android.os.Looper.loop(Looper.java:123)
11-17 09:34:35.272: ERROR/AndroidRuntime(277): at android.app.ActivityThread.main(ActivityThread.java:4627)
11-17 09:34:35.272: ERROR/AndroidRuntime(277): at java.lang.reflect.Method.invokeNative(Native Method)
11-17 09:34:35.272: ERROR/AndroidRuntime(277): at java.lang.reflect.Method.invoke(Method.java:521)
11-17 09:34:35.272: ERROR/AndroidRuntime(277): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-17 09:34:35.272: ERROR/AndroidRuntime(277): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-17 09:34:35.272: ERROR/AndroidRuntime(277): at dalvik.system.NativeStart.main(Native Method)
11-17 09:34:35.272: ERROR/AndroidRuntime(277): Caused by: java.lang.ClassNotFoundException: com.handerTest.HanderActivity in loader dalvik.system.PathClassLoader[/data/app/com.handerTest-1.apk]
11-17 09:34:35.272: ERROR/AndroidRuntime(277): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
11-17 09:34:35.272: ERROR/AndroidRuntime(277): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
11-17 09:34:35.272: ERROR/AndroidRuntime(277): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
11-17 09:34:35.272: ERROR/AndroidRuntime(277): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
11-17 09:34:35.272: ERROR/AndroidRuntime(277): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
11-17 09:34:35.272: ERROR/AndroidRuntime(277): ... 11 more
如果单单是按钮之类的组件的话就不会出现这种错误,
但是加了监听就出现了,为什么啊 异常信息我贴了给大家,
11-17 09:32:59.402: ERROR/Zygote(33): setreuid() failed. errno: 2
11-17 09:33:14.923: ERROR/Zygote(33): setreuid() failed. errno: 17
11-17 09:33:18.012: ERROR/BatteryService(69): usbOnlinePath not found
11-17 09:33:18.012: ERROR/BatteryService(69): batteryVoltagePath not found
11-17 09:33:18.022: ERROR/BatteryService(69): batteryTemperaturePath not found
11-17 09:33:18.092: ERROR/SurfaceFlinger(69): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake
11-17 09:33:29.351: ERROR/EventHub(69): could not get driver version for /dev/input/mouse0, Not a typewriter
11-17 09:33:29.351: ERROR/EventHub(69): could not get driver version for /dev/input/mice, Not a typewriter
11-17 09:33:29.772: ERROR/System(69): Failure starting core service
11-17 09:33:29.772: ERROR/System(69): java.lang.SecurityException
11-17 09:33:29.772: ERROR/System(69): at android.os.BinderProxy.transact(Native Method)
11-17 09:33:29.772: ERROR/System(69): at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146)
11-17 09:33:29.772: ERROR/System(69): at android.os.ServiceManager.addService(ServiceManager.java:72)
11-17 09:33:29.772: ERROR/System(69): at com.android.server.ServerThread.run(SystemServer.java:184)
11-17 09:33:32.382: ERROR/SoundPool(69): error loading /system/media/audio/ui/Effect_Tick.ogg
11-17 09:33:32.402: ERROR/SoundPool(69): error loading /system/media/audio/ui/KeypressStandard.ogg
11-17 09:33:32.431: ERROR/SoundPool(69): error loading /system/media/audio/ui/KeypressSpacebar.ogg
11-17 09:33:32.463: ERROR/SoundPool(69): error loading /system/media/audio/ui/KeypressDelete.ogg
11-17 09:33:32.483: ERROR/SoundPool(69): error loading /system/media/audio/ui/KeypressReturn.ogg
11-17 09:33:38.032: ERROR/ThrottleService(69): Could not open GPS configuration file /etc/gps.conf
11-17 09:33:39.711: ERROR/logwrapper(143): executing /system/bin/tc failed: No such file or directory
11-17 09:33:39.823: ERROR/logwrapper(146): executing /system/bin/tc failed: No such file or directory
11-17 09:33:39.982: ERROR/logwrapper(147): executing /system/bin/tc failed: No such file or directory
11-17 09:34:35.272: ERROR/AndroidRuntime(277): FATAL EXCEPTION: main
11-17 09:34:35.272: ERROR/AndroidRuntime(277): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.handerTest/com.handerTest.HanderActivity}: java.lang.ClassNotFoundException: com.handerTest.HanderActivity in loader dalvik.system.PathClassLoader[/data/app/com.handerTest-1.apk]
11-17 09:34:35.272: ERROR/AndroidRuntime(277): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
11-17 09:34:35.272: ERROR/AndroidRuntime(277): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
11-17 09:34:35.272: ERROR/AndroidRuntime(277): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
11-17 09:34:35.272: ERROR/AndroidRuntime(277): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
11-17 09:34:35.272: ERROR/AndroidRuntime(277): at android.os.Handler.dispatchMessage(Handler.java:99)
11-17 09:34:35.272: ERROR/AndroidRuntime(277): at android.os.Looper.loop(Looper.java:123)
11-17 09:34:35.272: ERROR/AndroidRuntime(277): at android.app.ActivityThread.main(ActivityThread.java:4627)
11-17 09:34:35.272: ERROR/AndroidRuntime(277): at java.lang.reflect.Method.invokeNative(Native Method)
11-17 09:34:35.272: ERROR/AndroidRuntime(277): at java.lang.reflect.Method.invoke(Method.java:521)
11-17 09:34:35.272: ERROR/AndroidRuntime(277): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-17 09:34:35.272: ERROR/AndroidRuntime(277): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-17 09:34:35.272: ERROR/AndroidRuntime(277): at dalvik.system.NativeStart.main(Native Method)
11-17 09:34:35.272: ERROR/AndroidRuntime(277): Caused by: java.lang.ClassNotFoundException: com.handerTest.HanderActivity in loader dalvik.system.PathClassLoader[/data/app/com.handerTest-1.apk]
11-17 09:34:35.272: ERROR/AndroidRuntime(277): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
11-17 09:34:35.272: ERROR/AndroidRuntime(277): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
11-17 09:34:35.272: ERROR/AndroidRuntime(277): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
11-17 09:34:35.272: ERROR/AndroidRuntime(277): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
11-17 09:34:35.272: ERROR/AndroidRuntime(277): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
11-17 09:34:35.272: ERROR/AndroidRuntime(277): ... 11 more
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;public class HandlerActivity extends Activity {
/** Called when the activity is first created. */
//声明两个按钮控件
private Button startButton = null;
private Button endButton = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//根据控件的ID得到代表控件的对象,并未这两个按钮设置相应的监听器
startButton = (Button)findViewById(R.id.startButton);
startButton.setOnClickListener(new StartButtonListener());
endButton = (Button)findViewById(R.id.endButton);
endButton.setOnClickListener(new EndButtonListener());
}
class StartButtonListener implements OnClickListener{ @Override
public void onClick(View v) {
//调用Handler的post方法,将要执行的线程对象添加到队列当中
handler.post(updateThread);
}
}
class EndButtonListener implements OnClickListener{ @Override
public void onClick(View v) {
handler.removeCallbacks(updateThread);
}
}
//创建一个Handler对象
Handler handler = new Handler();
//将要执行的操作写在线程对象的run方法当中
Runnable updateThread = new Runnable(){ @Override
public void run() {
System.out.println("UpdateThread");
//在run方法内部,执行postDelayed或者是post方法
handler.postDelayed(updateThread, 3000);
}
};
}
重新建个工程试试吧。
public class AndTest extends Activity {
private Button startButton = null;
private Button endButton = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//
startButton = (Button)findViewById(R.id.startButton);
startButton.setOnClickListener(new StartButtonListener());
endButton = (Button)findViewById(R.id.endButton);
endButton.setOnClickListener(new EndButtonListener());
} class StartButtonListener implements OnClickListener{ @Override
public void onClick(View v) {
//
handler.post(updateThread);
Log.i("AndTest", "start...");
}
}
class EndButtonListener implements OnClickListener{
@Override
public void onClick(View v) {
Log.i("AndTest", "end...");
handler.removeCallbacks(updateThread);
}
}
//
Handler handler = new Handler();
//
Runnable updateThread = new Runnable(){
@Override
public void run() {
System.out.println("UpdateThread");
//
handler.postDelayed(updateThread, 3000);
}
};
}
先重新建个AVD试试,
再不行就重新配置一下环境吧。