First of all I am new to android. I went through many similar question in SO but none of them make sense to me. I can't get my application running. All I see on the emulator is "Unfortunately {app_name} has stopped". Don't know how to fix it.
Here is my Manifest file:
<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): error opening trace file: No such file or directory (2) 02-03 01:49:59.255: W/Trace(3815): Unexpected value from nativeGetEnabledTags: 0 02-03 01:49:59.255: W/Trace(3815): Unexpected value from nativeGetEnabledTags: 0 02-03 01:49:59.255: W/Trace(3815): Unexpected value from nativeGetEnabledTags: 0 02-03 01:49:59.314: W/Trace(3815): Unexpected value from nativeGetEnabledTags: 0 02-03 01:49:59.314: W/Trace(3815): Unexpected value from nativeGetEnabledTags: 0 02-03 01:49:59.334: W/Trace(3815): Unexpected value from nativeGetEnabledTags: 0 02-03 01:49:59.334: W/Trace(3815): Unexpected value from nativeGetEnabledTags: 0 02-03 01:49:59.334: D/AndroidRuntime(3815): Shutting down VM 02-03 01:49:59.334: W/dalvikvm(3815): threadid=1: thread exiting with uncaught exception (group=0xb2d2e908) 02-03 01:49:59.364: E/AndroidRuntime(3815): FATAL EXCEPTION: main 02-03 01:49:59.364: E/AndroidRuntime(3815): java.lang.RuntimeException: Unable to instantiate activity Comp onentInfo{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): Caused by: 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/Andro idRuntime(3815): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097) 02-03 01:49:59.364: E/AndroidRuntime(3815): ... 11 more
It could be you exceeded the memory allowed by the app. Do you have a lot of images or inputs in the app? You could try decreasing the amount of memory used.
it is not able to find your activity. check your activity name or any other spelling mistake. see here in log cat. it is giving null pointer exception
02-03 01:49:59.255: E/Trace(3815): error opening trace file: No such file or directory (2) 02-03 01:49:59.255: W/Trace(3815): Unexpected value from nativeGetEnabledTags: 0 02-03 01:49:59.255: W/Trace(3815): Unexpected value from nativeGetEnabledTags: 0 02-03 01:49:59.255: W/Trace(3815): Unexpected value from nativeGetEnabledTags: 0 02-03 01:49:59.314: W/Trace(3815): Unexpected value from nativeGetEnabledTags: 0 02-03 01:49:59.314: W/Trace(3815): Unexpected value from nativeGetEnabledTags: 0 02-03 01:49:59.334: W/Trace(3815): Unexpected value from nativeGetEnabledTags: 0 02-03 01:49:59.334: W/Trace(3815): Unexpected value from nativeGetEnabledTags: 0 02-03 01:49:59.334: D/AndroidRuntime(3815): Shutting down VM 02-03 01:49:59.334: W/dalvikvm(3815): threadid=1: thread exiting with uncaught exception (group=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.inter nal.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): Caused by: 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/A ndroidRuntime(3815): ... 11 more
android:name=".MainActivity"
You should specify the whole class name including package
Example
android:name="com.example.MainActivity"
where com.example
is your package
Otherwise it cant identify your class
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.