the application DecRa (process com.Decra) has stopped unexpectedly.Please try again
<p>logcat:</p>

<pre><code>05-30 15:22:38.925: E/asset(16666): MAS: getAppPckgAndVerCode package: com.Decra === version 1
05-30 15:22:39.035: W/dalvikvm(16666): threadid=1: thread exiting with uncaught exception (group=0x40028890)
05-30 15:22:39.065: E/AndroidRuntime(16666): FATAL EXCEPTION: main
05-30 15:22:39.065: E/AndroidRuntime(16666): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.Decra/com.Decra.DecRaActivity}: java.lang.NullPointerException
05-30 15:22:39.065: E/AndroidRuntime(16666):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
05-30 15:22:39.065: E/AndroidRuntime(16666):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-30 15:22:39.065: E/AndroidRuntime(16666):    at android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-30 15:22:39.065: E/AndroidRuntime(16666):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-30 15:22:39.065: E/AndroidRuntime(16666):    at android.os.Handler.dispatchMessage(Handler.java:99)
05-30 15:22:39.065: E/AndroidRuntime(16666):    at android.os.Looper.loop(Looper.java:123)
05-30 15:22:39.065: E/AndroidRuntime(16666):    at android.app.ActivityThread.main(ActivityThread.java:4627)
05-30 15:22:39.065: E/AndroidRuntime(16666):    at java.lang.reflect.Method.invokeNative(Native Method)
05-30 15:22:39.065: E/AndroidRuntime(16666):    at java.lang.reflect.Method.invoke(Method.java:521)
05-30 15:22:39.065: E/AndroidRuntime(16666):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
05-30 15:22:39.065: E/AndroidRuntime(16666):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
05-30 15:22:39.065: E/AndroidRuntime(16666):    at dalvik.system.NativeStart.main(Native Method)
05-30 15:22:39.065: E/AndroidRuntime(16666): Caused by: java.lang.NullPointerException
05-30 15:22:39.065: E/AndroidRuntime(16666):    at android.app.Activity.findViewById(Activity.java:1637)
05-30 15:22:39.065: E/AndroidRuntime(16666):    at com.Decra.DecRaActivity.&lt;init&gt;(DecRaActivity.java:13)
05-30 15:22:39.065: E/AndroidRuntime(16666):    at java.lang.Class.newInstanceImpl(Native Method)
05-30 15:22:39.065: E/AndroidRuntime(16666):    at java.lang.Class.newInstance(Class.java:1429)
05-30 15:22:39.065: E/AndroidRuntime(16666):    at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
05-30 15:22:39.065: E/AndroidRuntime(16666):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
05-30 15:22:39.065: E/AndroidRuntime(16666):    ... 11 more
</code></pre>

<p>code:</p>

<pre><code>package com.Decra;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import java.lang.Math;
import java.util.Calendar;

public class DecRaActivity extends Activity implements View.OnClickListener {
    /** Called when the activity is first created. */
    TextView dectv=(TextView)findViewById(R.id.dec);
    TextView ratv=(TextView)findViewById(R.id.ra);
    TextView result=(TextView)findViewById(R.id.result);
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Button btn=new Button(this);
        btn.setOnClickListener(this);
    }
    public void onClick(View view){
        CharSequence decch=dectv.getText();
        CharSequence rach=ratv.getText();
        String decst=decch.toString();
        String rast=rach.toString();
        float dec= Float.parseFloat(decst);
        float ra= Float.parseFloat(rast);
        float altaz[]=getdecra(dec,ra);
        float alt=altaz[0];
        float az=altaz[1];
        String altst=Float.toString(alt);
        String azst=Float.toString(az);
        String tex="alt : "+altst+"\n az : "+azst;
        result.setText(tex);
    }
    private float[] getdecra(float dec,float ra) {
        double lat=30.05/180*Math.PI;
        double lon=31.25/180*Math.PI;
        dec=(float) (dec/180.0*Math.PI);
        ra=(float) ((ra*360/24.0)/180*Math.PI);
        float lmst=(float) (t2lmst()/180.0*Math.PI);
        float ha=lmst - ra;
        float salt=(float) (Math.sin(dec)*Math.sin(lat)+Math.cos(dec)*Math.cos(lat)*Math.cos(ha));
        if (salt&gt;1){
                    salt=1;}
        else if (salt&lt;-1){
                    salt=-1;}
        float alt=(float) Math.asin(salt);
        float sa=(float) ((Math.sin(dec)-Math.sin(alt)*Math.sin(lat))/(Math.cos(alt)*Math.cos(lat)));
        if (sa&gt;1){
                    sa=1;}
        else if (sa&lt;-1){
                    sa=-1;}
        float a=(float) Math.acos(sa);
        float az;
        if (Math.sin(ha)&lt;0){
            az=a;}
        else{
            az=(float) (2*Math.PI-a);}
        float falt=r2d(alt);
        float faz=r2d(az);
        float altaz[]={falt,faz};
        return altaz;
    }
    private float t2lmst(){
        int month=Calendar.DAY_OF_MONTH;
        int year=Calendar.YEAR;
        int day=Calendar.DAY_OF_MONTH;
        int hour=Calendar.HOUR;
        int minute=Calendar.MINUTE;
        int second=Calendar.SECOND;
        month+=1;
        if (month==1 | month==2){
            month+=12;
            year-=1;
        }
        float a=(float) Math.floor(year/100);
        float b=(float) (2-a+Math.floor(a/4));
        float c=(float) Math.floor(365.25*year);
        float d=(float) Math.floor(30.6001*(month+1));
        float jd=(float) (b+c+d-730550.5+day+(hour+minute/60.0 +second/3600.0)/24.0);
        float jt=(float) (jd/36525.0);
        float mst=(float) (280.46061837+360.98564736629*jd+0.000387933*jt*jt-jt*jt*jt/38710000);
        float res=mst%360;
        res-=30;
        if (res&lt;0){
            res+=360;
        }
        return res;
    }
    private float d2r(float n){
        return (float) (n*Math.PI/180.0);
    }
    private float r2d(float d){
        return (float) (d/Math.PI*180.0);
    }
    private float cos(float n){
        return (float) Math.cos(d2r(n));
    }
    private float sin(float n){
        return (float) Math.sin(d2r(n));
    }
    private float tan(float n){
        return (float) Math.tan(d2r(n));
    }
    private float acos(float n){
        return r2d((float) Math.acos(n));
    }
    private float asin(float n){
        return r2d((float) Math.asin(n));
    }
    private float atan(float n){
        return r2d((float) Math.atan(n));
    }
}
</code></pre>

<p>when launching the program it just appears then disappears and gets an alert :</p>

<p>"the application DecRa (process com.Decra) has stopped unexpectedly.Please try again."</p>

<p>and there is no errors in the compiler so it must be run time errors but i don't get the errors and what i understood is that one of the errors refer to findViewById</p>
