【发布时间】:2013-06-04 18:08:34
【问题描述】:
当我尝试运行我的应用程序时,启动画面正确显示,并且在它关闭后立即弹出一条消息,上面写着“不幸的是,第一个应用程序已停止工作”我尝试了很多不同的解决方案我'已经发现,但我相信在我的情况下,在模拟器中测试新的“Hello World”应用程序后,我的代码存在问题。这是我的 androidmanifest.xml 的副本
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.examle.firstapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Splash" android:label="@string/app_name" >
<intent-filter>
<action android:name="com.example.firstapp.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity" android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAINACTIVTY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
这是在尝试了一些解决方案后出现在 log cat 中的内容
06-08 16:12:06.849: E/AndroidRuntime(2821): FATAL EXCEPTION: main
06-08 16:12:06.849: E/AndroidRuntime(2821): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.firstapp/com.example.firstapp.Splash}: java.lang.ClassNotFoundException: Didn't find class "com.example.firstapp.Splash" on path: /data/app/com.example.firstapp-1.apk
06-08 16:12:06.849: E/AndroidRuntime(2821): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
06-08 16:12:06.849: E/AndroidRuntime(2821): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
06-08 16:12:06.849: E/AndroidRuntime(2821): at android.app.ActivityThread.access$600(ActivityThread.java:141)
06-08 16:12:06.849: E/AndroidRuntime(2821): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
06-08 16:12:06.849: E/AndroidRuntime(2821): at android.os.Handler.dispatchMessage(Handler.java:99)
06-08 16:12:06.849: E/AndroidRuntime(2821): at android.os.Looper.loop(Looper.java:137)
06-08 16:12:06.849: E/AndroidRuntime(2821): at android.app.ActivityThread.main(ActivityThread.java:5041)
06-08 16:12:06.849: E/AndroidRuntime(2821): at java.lang.reflect.Method.invokeNative(Native Method)
06-08 16:12:06.849: E/AndroidRuntime(2821): at java.lang.reflect.Method.invoke(Method.java:511)
06-08 16:12:06.849: E/AndroidRuntime(2821): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-08 16:12:06.849: E/AndroidRuntime(2821): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-08 16:12:06.849: E/AndroidRuntime(2821): at dalvik.system.NativeStart.main(Native Method)
06-08 16:12:06.849: E/AndroidRuntime(2821): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.firstapp.Splash" on path: /data/app/com.example.firstapp-1.apk
06-08 16:12:06.849: E/AndroidRuntime(2821): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
06-08 16:12:06.849: E/AndroidRuntime(2821): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
06-08 16:12:06.849: E/AndroidRuntime(2821): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
06-08 16:12:06.849: E/AndroidRuntime(2821): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
06-08 16:12:06.849: E/AndroidRuntime(2821): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
06-08 16:12:06.849: E/AndroidRuntime(2821): ... 11 more
我对android编程真的很陌生,所以如果你能在帮助我时具体一点,将不胜感激。
【问题讨论】:
-
哇,好吧,我什至没有意识到我在示例中打错了字。另一个错误正在弹出。
Description Resource Path Location Type The project was not built due to "A resource exists with a different case: '/FirstApp/bin/classes/com/examle/firstapp'.". Fix the problem, then try refreshing this project and building it since it may be inconsistent FirstApp Unknown Java Problem -
你的 java 文件中的包名是什么?似乎是包名不匹配。是不是像
package com.example.firstapp; -
包名中有大写字母,我现在刚刚修好了。现在该错误消失了,但是现在当我尝试运行该应用程序时,启动画面根本不显示,它告诉我它已停止工作。
-
您是否尝试过我的回答中提到的编辑?发布崩溃的新 logcat 详细信息
-
是的,我试过了,没有运气。
标签: android android-emulator android-manifest