首先,我是android新手。我在SO中经历了许多类似的问题,但没有一个对我有意义。我无法运行我的应用程序。我在模拟器上看到的只是“不幸{app_name}已停止”。不知道如何解决它。
这是我的清单文件:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:debuggable="true"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
logcat的:
02-03 01:49:59.255:E / Trace(3815):错误打开跟踪文件:没有这样的 文件或目录(2)02-03 01:49:59.255:W / Trace(3815):意外 来自nativeGetEnabledTags的值:0 02-03 01:49:59.255:W / Trace(3815): 来自nativeGetEnabledTags的意外值:0 02-03 01:49:59.255: W / Trace(3815):来自nativeGetEnabledTags的意外值:0 02-03 01:49:59.314:W / Trace(3815):来自的意外值 nativeGetEnabledTags:0 02-03 01:49:59.314:W / Trace(3815):意外 来自nativeGetEnabledTags的值:0 02-03 01:49:59.334:W / Trace(3815): 来自nativeGetEnabledTags的意外值:0 02-03 01:49:59.334: W / Trace(3815):来自nativeGetEnabledTags的意外值:0 02-03 01:49:59.334:D / AndroidRuntime(3815):关闭VM 02-03 01:49:59.334:W / dalvikvm(3815):threadid = 1:线程退出 未捕获的异常(组= 0xb2d2e908)02-03 01:49:59.364: E / AndroidRuntime(3815):致命异常:主02-03 01:49:59.364: E / AndroidRuntime(3815):java.lang.RuntimeException:无法 实例化活动 ComponentInfo {com.example.rupantar / com.example.rupantar.MainActivity}: java.lang.NullPointerException 02-03 01:49:59.364: E / AndroidRuntime(3815):at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106) 02-03 01:49:59.364:E / AndroidRuntime(3815):at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 02-03 01:49:59.364:E / AndroidRuntime(3815):at android.app.ActivityThread.access $ 600(ActivityThread.java:141)02-03 01:49:59.364:E / AndroidRuntime(3815):at android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1234) 02-03 01:49:59.364:E / AndroidRuntime(3815):at android.os.Handler.dispatchMessage(Handler.java:99)02-03 01:49:59.364:E / AndroidRuntime(3815):at android.os.Looper.loop(Looper.java:137)02-03 01:49:59.364: E / AndroidRuntime(3815):at android.app.ActivityThread.main(ActivityThread.java:5039)02-03 01:49:59.364:E / AndroidRuntime(3815):at java.lang.reflect.Method.invokeNative(Native Method)02-03 01:49:59.364:E / AndroidRuntime(3815):at java.lang.reflect.Method.invoke(Method.java:511)02-03 01:49:59.364: E / AndroidRuntime(3815):at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:793) 02-03 01:49:59.364:E / AndroidRuntime(3815):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)02-03 01:49:59.364:E / AndroidRuntime(3815):at dalvik.system.NativeStart.main(Native Method)02-03 01:49:59.364: E / AndroidRuntime(3815):引起:java.lang.NullPointerException 02-03 01:49:59.364:E / AndroidRuntime(3815):at android.app.Activity.findViewById(Activity.java:1839)02-03 01:49:59.364:E / AndroidRuntime(3815):at com.example.rupantar.MainActivity。(MainActivity.java:37)02-03 01:49:59.364:E / AndroidRuntime(3815):at java.lang.Class.newInstanceImpl(Native Method)02-03 01:49:59.364: E / AndroidRuntime(3815):at java.lang.Class.newInstance(Class.java:1319)02-03 01:49:59.364: E / AndroidRuntime(3815):at android.app.Instrumentation.newActivity(Instrumentation.java:1054) 02-03 01:49:59.364:E / AndroidRuntime(3815):at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097) 02-03 01:49:59.364:E / AndroidRuntime(3815):... 11更多
答案 0 :(得分:0)
可能是你超出了应用程序允许的内存。你在应用程序中有很多图像或输入吗?您可以尝试减少使用的内存量。
答案 1 :(得分:0)
无法找到您的活动。检查您的活动名称或任何其他拼写错误。 在log cat中看到这里。它给出了空指针异常
02-03 01:49:59.255:E / Trace(3815):错误打开跟踪文件:没有这样的 文件或目录(2)02-03 01:49:59.255:W / Trace(3815):意外 来自nativeGetEnabledTags的值:0 02-03 01:49:59.255:W / Trace(3815): 来自nativeGetEnabledTags的意外值:0 02-03 01:49:59.255: W / Trace(3815):来自nativeGetEnabledTags的意外值:0 02-03 01:49:59.314:W / Trace(3815):来自的意外值 nativeGetEnabledTags:0 02-03 01:49:59.314:W / Trace(3815):意外 来自nativeGetEnabledTags的值:0 02-03 01:49:59.334:W / Trace(3815): 来自nativeGetEnabledTags的意外值:0 02-03 01:49:59.334: W / Trace(3815):来自nativeGetEnabledTags的意外值:0 02-03 01:49:59.334:D / AndroidRuntime(3815):关闭VM 02-03 01:49:59.334:W / dalvikvm(3815):threadid = 1:线程退出 未捕获的异常(组= 0xb2d2e908)02-03 01:49:59.364: E / AndroidRuntime(3815):*
*
E / AndroidRuntime(3815):at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106) 02-03 01:49:59.364:E / AndroidRuntime(3815):at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 02-03 01:49:59.364:E / AndroidRuntime(3815):at android.app.ActivityThread.access $ 600(ActivityThread.java:141)02-03 01:49:59.364:E / AndroidRuntime(3815):at android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1234) 02-03 01:49:59.364:E / AndroidRuntime(3815):at android.os.Handler.dispatchMessage(Handler.java:99)02-03 01:49:59.364:E / AndroidRuntime(3815):at android.os.Looper.loop(Looper.java:137)02-03 01:49:59.364: E / AndroidRuntime(3815):at android.app.ActivityThread.main(ActivityThread.java:5039)02-03 01:49:59.364:E / AndroidRuntime(3815):at java.lang.reflect.Method.invokeNative(Native Method)02-03 01:49:59.364:E / AndroidRuntime(3815):at java.lang.reflect.Method.invoke(Method.java:511)02-03 01:49:59.364: E / AndroidRuntime(3815):at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:793) 02-03 01:49:59.364:E / AndroidRuntime(3815):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)02-03 01:49:59.364:E / AndroidRuntime(3815):at dalvik.system.NativeStart.main(Native Method)02-03 01:49:59.364: E / AndroidRuntime(3815):引起:java.lang.NullPointerException 02-03 01:49:59.364:E / AndroidRuntime(3815):at android.app.Activity.findViewById(Activity.java:1839)02-03 01:49:59.364:E / AndroidRuntime(3815):at com.example.rupantar.MainActivity。(MainActivity.java:37)02-03 01:49:59.364:E / AndroidRuntime(3815):at java.lang.Class.newInstanceImpl(Native Method)02-03 01:49:59.364: E / AndroidRuntime(3815):at java.lang.Class.newInstance(Class.java:1319)02-03 01:49:59.364: E / AndroidRuntime(3815):at android.app.Instrumentation.newActivity(Instrumentation.java:1054) 02-03 01:49:59.364:E / AndroidRuntime(3815):at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097) 02-03 01:49:59.364:E / AndroidRuntime(3815):... 11更多
答案 2 :(得分:0)
android:name=".MainActivity"
您应该指定整个类名,包括包
示例强>
android:name="com.example.MainActivity"
其中com.example
是您的包
否则它无法识别您的班级