Tuesday 17 October 2017

java - Unfortunately my app has stopped in Android Emulator





I've been looking for an answer for hours now, but my calculator
wont work at all :(



I appreciate if you could
help me. I've posted the manifest code below. Inform me if you need to see the
MainActivity.java or anything else
:)



             encoding="utf-8"?>
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.elof_calc_2000_dragonslayerxx"

android:versionCode="1"
android:versionName="1.0"
>

android:minSdkVersion="15"

android:targetSdkVersion="17" />


android:allowBackup="true"

android:icon="@drawable/ic_launcher"


android:label="@string/app_name"
android:theme="@style/AppTheme"
>

android:name="com.example.elof_calc_2000_dragonslayerxx.MainActivity"

android:label="@string/app_name" >
















The
errors shown on Logcat



03-16
18:09:59.890: E/AndroidRuntime(895): FATAL EXCEPTION: main
03-16 18:09:59.890:
E/AndroidRuntime(895): Process: com.example.elof_calc_2000_dragonslayerxx, PID:
895

03-16 18:09:59.890: E/AndroidRuntime(895):
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.example.elof_calc_2000_dragonslayerxx/com.example.elof_calc_2000_dragonslayerxx.MainActivity}:
java.lang.NullPointerException
03-16 18:09:59.890: E/AndroidRuntime(895): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
03-16
18:09:59.890: E/AndroidRuntime(895): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
03-16
18:09:59.890: E/AndroidRuntime(895): at
android.app.ActivityThread.access$800(ActivityThread.java:135)
03-16
18:09:59.890: E/AndroidRuntime(895): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
03-16
18:09:59.890: E/AndroidRuntime(895): at
android.os.Handler.dispatchMessage(Handler.java:102)
03-16 18:09:59.890:
E/AndroidRuntime(895): at android.os.Looper.loop(Looper.java:136)
03-16
18:09:59.890: E/AndroidRuntime(895): at
android.app.ActivityThread.main(ActivityThread.java:5017)
03-16 18:09:59.890:
E/AndroidRuntime(895): at java.lang.reflect.Method.invokeNative(Native
Method)
03-16 18:09:59.890: E/AndroidRuntime(895): at
java.lang.reflect.Method.invoke(Method.java:515)

03-16
18:09:59.890: E/AndroidRuntime(895): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
03-16
18:09:59.890: E/AndroidRuntime(895): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
03-16
18:09:59.890: E/AndroidRuntime(895): at dalvik.system.NativeStart.main(Native
Method)
03-16 18:09:59.890: E/AndroidRuntime(895): Caused by:
java.lang.NullPointerException
03-16 18:09:59.890: E/AndroidRuntime(895): at
com.example.elof_calc_2000_dragonslayerxx.MainActivity.onClickListeners(MainActivity.java:49)
03-16
18:09:59.890: E/AndroidRuntime(895): at
com.example.elof_calc_2000_dragonslayerxx.MainActivity.onCreate(MainActivity.java:22)
03-16
18:09:59.890: E/AndroidRuntime(895): at
android.app.Activity.performCreate(Activity.java:5231)
03-16 18:09:59.890:
E/AndroidRuntime(895): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
03-16
18:09:59.890: E/AndroidRuntime(895): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
03-16
18:09:59.890: E/AndroidRuntime(895): ... 11 more

03-16
18:16:23.316: E/AndroidRuntime(1100): FATAL EXCEPTION: main
03-16
18:16:23.316: E/AndroidRuntime(1100): Process:
com.example.elof_calc_2000_dragonslayerxx, PID: 1100
03-16 18:16:23.316:
E/AndroidRuntime(1100): java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.example.elof_calc_2000_dragonslayerxx/com.example.elof_calc_2000_dragonslayerxx.MainActivity}:
java.lang.NullPointerException
03-16 18:16:23.316: E/AndroidRuntime(1100): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
03-16
18:16:23.316: E/AndroidRuntime(1100): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
03-16
18:16:23.316: E/AndroidRuntime(1100): at
android.app.ActivityThread.access$800(ActivityThread.java:135)
03-16
18:16:23.316: E/AndroidRuntime(1100): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
03-16
18:16:23.316: E/AndroidRuntime(1100): at
android.os.Handler.dispatchMessage(Handler.java:102)
03-16 18:16:23.316:
E/AndroidRuntime(1100): at android.os.Looper.loop(Looper.java:136)
03-16
18:16:23.316: E/AndroidRuntime(1100): at
android.app.ActivityThread.main(ActivityThread.java:5017)

03-16
18:16:23.316: E/AndroidRuntime(1100): at java.lang.reflect.Method.invokeNative(Native
Method)
03-16 18:16:23.316: E/AndroidRuntime(1100): at
java.lang.reflect.Method.invoke(Method.java:515)
03-16 18:16:23.316:
E/AndroidRuntime(1100): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
03-16
18:16:23.316: E/AndroidRuntime(1100): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
03-16
18:16:23.316: E/AndroidRuntime(1100): at dalvik.system.NativeStart.main(Native
Method)
03-16 18:16:23.316: E/AndroidRuntime(1100): Caused by:
java.lang.NullPointerException
03-16 18:16:23.316: E/AndroidRuntime(1100): at
com.example.elof_calc_2000_dragonslayerxx.MainActivity.onClickListeners(MainActivity.java:49)
03-16
18:16:23.316: E/AndroidRuntime(1100): at
com.example.elof_calc_2000_dragonslayerxx.MainActivity.onCreate(MainActivity.java:22)
03-16
18:16:23.316: E/AndroidRuntime(1100): at
android.app.Activity.performCreate(Activity.java:5231)
03-16 18:16:23.316:
E/AndroidRuntime(1100): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)

03-16
18:16:23.316: E/AndroidRuntime(1100): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
03-16
18:16:23.316: E/AndroidRuntime(1100): ... 11
more

class="post-text" itemprop="text">
class="normal">Answer



Here are
your key lines



03-16
18:16:23.316: E/AndroidRuntime(1100): Caused by:
java.lang.NullPointerException
03-16 18:16:23.316: E/AndroidRuntime(1100): at
com.example.elof_calc_2000_dragonslayerxx.MainActivity.onClickListeners(MainActivity.java:49)



You
have a NullPointerException on line 49 of your MainActivity. You can post that for
further help. Whatever code is there ensure that it is initialized (and thus not null)
before you call it.


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...