Tuesday, 27 August 2013

Unfortunately, App has Stopped Android Deevelopment Error

Unfortunately, App has Stopped Android Deevelopment Error

when I try to open up a new activity called areacircle, it shows the
error: "Unfortunately, Essentials has Stopped". I am 100% sure that the
problem does not consist in the Manifest file. I think there might be some
problem in my code.
areacircle code:
package com.turnapps.essentials;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class areacircle extends Activity {
TextView textView1 = (EditText) findViewById(R.id.textView1);
TextView textView2 = (EditText) findViewById(R.id.textView2);
private static double radius;
Button button1 = (Button) findViewById(R.id.button1);
EditText radiusedittext = (EditText) findViewById(R.id.radiusedittext);
TextView answer = (EditText) findViewById(R.id.answer);
private double pi = 3.14;
private double radiusedittext1 = radius;
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.areacircle);
}
public void findarea(View sender){
double areatextview;
areatextview = radiusedittext1 * radiusedittext1 * pi;
answer.getText().equals(areatextview);
}
}
Here is the code of findmy (the activity where I am launching areacircle
from):
public class findmy extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.findmy);
Button d = (Button) findViewById(R.id.circleareabtn);
d.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent acircleIntent = new Intent(view.getContext(),
areacircle.class);
startActivity(acircleIntent);
}
});
}
}
Here is the LogCat content:
08-27 14:09:43.621: D/gralloc_goldfish(2691): Emulator without GPU
emulation detected.
08-27 14:09:51.122: D/dalvikvm(2691): GC_CONCURRENT freed 159K, 10% free
2611K/2900K, paused 71ms+116ms, total 325ms
08-27 14:09:56.772: D/AndroidRuntime(2691): Shutting down VM
08-27 14:09:56.811: W/dalvikvm(2691): threadid=1: thread exiting with
uncaught exception (group=0x40a71930)
08-27 14:09:56.911: E/AndroidRuntime(2691): FATAL EXCEPTION: main
08-27 14:09:56.911: E/AndroidRuntime(2691): java.lang.RuntimeException:
Unable to instantiate activity
ComponentInfo{com.turnapps.essentials/com.turnapps.essentials.areacircle}:
java.lang.NullPointerException
08-27 14:09:56.911: E/AndroidRuntime(2691): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
08-27 14:09:56.911: E/AndroidRuntime(2691): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
08-27 14:09:56.911: E/AndroidRuntime(2691): at
android.app.ActivityThread.access$600(ActivityThread.java:141)
08-27 14:09:56.911: E/AndroidRuntime(2691): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
08-27 14:09:56.911: E/AndroidRuntime(2691): at
android.os.Handler.dispatchMessage(Handler.java:99)
08-27 14:09:56.911: E/AndroidRuntime(2691): at
android.os.Looper.loop(Looper.java:137)
08-27 14:09:56.911: E/AndroidRuntime(2691): at
android.app.ActivityThread.main(ActivityThread.java:5041)
08-27 14:09:56.911: E/AndroidRuntime(2691): at
java.lang.reflect.Method.invokeNative(Native Method)
08-27 14:09:56.911: E/AndroidRuntime(2691): at
java.lang.reflect.Method.invoke(Method.java:511)
08-27 14:09:56.911: E/AndroidRuntime(2691): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
08-27 14:09:56.911: E/AndroidRuntime(2691): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
08-27 14:09:56.911: E/AndroidRuntime(2691): at
dalvik.system.NativeStart.main(Native Method)
08-27 14:09:56.911: E/AndroidRuntime(2691): Caused by:
java.lang.NullPointerException
08-27 14:09:56.911: E/AndroidRuntime(2691): at
android.app.Activity.findViewById(Activity.java:1839)
08-27 14:09:56.911: E/AndroidRuntime(2691): at
com.turnapps.essentials.areacircle.<init>(areacircle.java:11)
08-27 14:09:56.911: E/AndroidRuntime(2691): at
java.lang.Class.newInstanceImpl(Native Method)
08-27 14:09:56.911: E/AndroidRuntime(2691): at
java.lang.Class.newInstance(Class.java:1319)
08-27 14:09:56.911: E/AndroidRuntime(2691): at
android.app.Instrumentation.newActivity(Instrumentation.java:1054)
08-27 14:09:56.911: E/AndroidRuntime(2691): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
08-27 14:09:56.911: E/AndroidRuntime(2691): ... 11 more

No comments:

Post a Comment