每当我尝试在模拟器中运行它时,我一直在开发一个 android 和应用程序它给了我这个错误:应用程序 Explicit_intents (process.com.andrewbook.explicit_intents) 已意外停止,请再试一次。
这是代码:
package com.andrewbook.explicit_intents;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class Main extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final EditText et = (EditText) findViewById(R.id.editText1);
Button b = (Button) findViewById(R.id.button1);
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Main.this, Second.class);
intent.putExtra("thetext", et.getText().toString());
startActivity(intent);
}
});
}
}
这是 logcat 输出:
04-09 13:20:32.632: E/AndroidRuntime(637): FATAL EXCEPTION: main
04-09 13:20:32.632: E/AndroidRuntime(637): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.andrewbook.explicit_intents/com.andrewbook.explicit_intents.Explicit_IntentsActivity}: java.lang.ClassNotFoundException: com.andrewbook.explicit_intents.Explicit_IntentsActivity in loader dalvik.system.PathClassLoader[/data/app/com.andrewbook.explicit_intents-2.apk]
04-09 13:20:32.632: E/AndroidRuntime(637): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
04-09 13:20:32.632: E/AndroidRuntime(637): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
04-09 13:20:32.632: E/AndroidRuntime(637): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-09 13:20:32.632: E/AndroidRuntime(637): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
04-09 13:20:32.632: E/AndroidRuntime(637): at android.os.Handler.dispatchMessage(Handler.java:99)
04-09 13:20:32.632: E/AndroidRuntime(637): at android.os.Looper.loop(Looper.java:123)
04-09 13:20:32.632: E/AndroidRuntime(637): at android.app.ActivityThread.main(ActivityThread.java:3683)
04-09 13:20:32.632: E/AndroidRuntime(637): at java.lang.reflect.Method.invokeNative(Native Method)
04-09 13:20:32.632: E/AndroidRuntime(637): at java.lang.reflect.Method.invoke(Method.java:507)
04-09 13:20:32.632: E/AndroidRuntime(637): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-09 13:20:32.632: E/AndroidRuntime(637): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-09 13:20:32.632: E/AndroidRuntime(637): at dalvik.system.NativeStart.main(Native Method)
04-09 13:20:32.632: E/AndroidRuntime(637): Caused by: java.lang.ClassNotFoundException: com.andrewbook.explicit_intents.Explicit_IntentsActivity in loader dalvik.system.PathClassLoader[/data/app/com.andrewbook.explicit_intents-2.apk]
04-09 13:20:32.632: E/AndroidRuntime(637): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
04-09 13:20:32.632: E/AndroidRuntime(637): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
04-09 13:20:32.632: E/AndroidRuntime(637): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
04-09 13:20:32.632: E/AndroidRuntime(637): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
04-09 13:20:32.632: E/AndroidRuntime(637): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
04-09 13:20:32.632: E/AndroidRuntime(637): ... 11 more
04-09 13:20:32.662: W/ActivityManager(75): Force finishing activity com.andrewbook.explicit_intents/.Explicit_IntentsActivity
04-09 13:20:33.171: W/ActivityManager(75): Activity pause timeout for HistoryRecord{4075b080 com.andrewbook.explicit_intents/.Explicit_IntentsActivity}
04-09 13:20:44.131: W/ActivityManager(75): Activity destroy timeout for HistoryRecord{4075b080 com.andrewbook.explicit_intents/.Explicit_IntentsActivity}
04-09 13:21:57.092: D/SntpClient(75): request time failed: java.net.SocketException: Address family not supported by protocol
04-09 13:25:32.681: I/Process(637): Sending signal. PID: 637 SIG: 9
04-09 13:25:32.702: I/ActivityManager(75): Process com.andrewbook.explicit_intents (pid 637) has died.
04-09 13:25:32.791: W/InputManagerService(75): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@4075fea8
04-09 13:26:57.101: D/SntpClient(75): request time failed: java.net.SocketException: Address family not supported by protocol
04-09 13:28:59.951: I/ActivityManager(75): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.andrewbook.explicit_intents/.Explicit_IntentsActivity } from pid 246
04-09 13:29:00.021: I/ActivityManager(75): Start proc com.andrewbook.explicit_intents for activity com.andrewbook.explicit_intents/.Explicit_IntentsActivity: pid=646 uid=10034 gids={}
04-09 13:29:00.782: D/AndroidRuntime(646): Shutting down VM
04-09 13:29:00.812: W/dalvikvm(646): threadid=1: thread exiting with uncaught exception (group=0x40015560)
04-09 13:29:00.872: E/AndroidRuntime(646): FATAL EXCEPTION: main
04-09 13:29:00.872: E/AndroidRuntime(646): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.andrewbook.explicit_intents/com.andrewbook.explicit_intents.Explicit_IntentsActivity}: java.lang.ClassNotFoundException: com.andrewbook.explicit_intents.Explicit_IntentsActivity in loader dalvik.system.PathClassLoader[/data/app/com.andrewbook.explicit_intents-2.apk]
04-09 13:29:00.872: E/AndroidRuntime(646): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
04-09 13:29:00.872: E/AndroidRuntime(646): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
04-09 13:29:00.872: E/AndroidRuntime(646): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-09 13:29:00.872: E/AndroidRuntime(646): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
04-09 13:29:00.872: E/AndroidRuntime(646): at android.os.Handler.dispatchMessage(Handler.java:99)
04-09 13:29:00.872: E/AndroidRuntime(646): at android.os.Looper.loop(Looper.java:123)
04-09 13:29:00.872: E/AndroidRuntime(646): at android.app.ActivityThread.main(ActivityThread.java:3683)
04-09 13:29:00.872: E/AndroidRuntime(646): at java.lang.reflect.Method.invokeNative(Native Method)
04-09 13:29:00.872: E/AndroidRuntime(646): at java.lang.reflect.Method.invoke(Method.java:507)
04-09 13:29:00.872: E/AndroidRuntime(646): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-09 13:29:00.872: E/AndroidRuntime(646): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-09 13:29:00.872: E/AndroidRuntime(646): at dalvik.system.NativeStart.main(Native Method)
04-09 13:29:00.872: E/AndroidRuntime(646): Caused by: java.lang.ClassNotFoundException: com.andrewbook.explicit_intents.Explicit_IntentsActivity in loader dalvik.system.PathClassLoader[/data/app/com.andrewbook.explicit_intents-2.apk]
04-09 13:29:00.872: E/AndroidRuntime(646): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
04-09 13:29:00.872: E/AndroidRuntime(646): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
04-09 13:29:00.872: E/AndroidRuntime(646): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
04-09 13:29:00.872: E/AndroidRuntime(646): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
04-09 13:29:00.872: E/AndroidRuntime(646): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
04-09 13:29:00.872: E/AndroidRuntime(646): ... 11 more
任何帮助将不胜感激。提前致谢