当我在Android1.5模拟器中启动应用程序时,我试图运行一个示例代码,我得到了以下错误.有人有什么暗示吗.?来自logcat的错误:01-13 02:28:08.392: ERROR/AndroidRuntime(2888): FATAL EXCEPTION: main01-13 02:28:08.392: ERROR/AndroidRuntime(2888): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.s.android.test/com.s.android.test.MainActivity}: java.lang.ClassNotFoundException: com.s.android.test.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.s.android.test-2.apk]01-13 02:28:08.392: ERROR/AndroidRuntime(2888): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1544)01-13 02:28:08.392: ERROR/AndroidRuntime(2888): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1638)01-13 02:28:08.392: ERROR/AndroidRuntime(2888): at android.app.ActivityThread.access$1500(ActivityThread.java:117)01-13 02:28:08.392: ERROR/AndroidRuntime(2888): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:928)01-13 02:28:08.392: ERROR/AndroidRuntime(2888): at android.os.Handler.dispatchMessage(Handler.java:99)01-13 02:28:08.392: ERROR/AndroidRuntime(2888): at android.os.Looper.loop(Looper.java:123)01-13 02:28:08.392: ERROR/AndroidRuntime(2888): at android.app.ActivityThread.main(ActivityThread.java:3647)01-13 02:28:08.392: ERROR/AndroidRuntime(2888): at java.lang.reflect.Method.invokeNative(Native Method)01-13 02:28:08.392: ERROR/AndroidRuntime(2888): at java.lang.reflect.Method.invoke(Method.java:507)01-13 02:28:08.392: ERROR/AndroidRuntime(2888): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)编辑这个错误发生在大多数初学者身上,问题是您必须将所有的活动都添加到Manifest文件中。
3 回答
四季花海
TA贡献1811条经验 获得超5个赞
Activity
AndroidManifest.xml
.
AndroidManifest.xml
.
森林海
TA贡献2011条经验 获得超2个赞
<application> .... <uses-library android:name="com.google.android.maps" /></application>
<activity android:name=".activities.MainActivity"/>
ABOUTYOU
TA贡献1812条经验 获得超5个赞
onCreate()
public class MainActivity extends Activity { ImageView mainImage = (ImageView) findViewById(R.id.imageViewMain); //incorrect @Override protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } ...}
添加回答
举报
0/150
提交
取消