Can't run my little Android code in Eclipse, I get this error message:
E/AndroidRuntime(275): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mytest.threedee/com.mytest.threedee.MainActivity}: java.lang.NullPointerException
What more info could be helpful? I guess my code is irrelevent because Eclipse fails to even start executing it. I do import java.lang.math.* Why does it say it's a "nullpointer"? The editor doesn't mark my math functions with any error. I suppose this is some obscure path problem with Eclipse.
Project/properties/Order and Export only lists: - 2Dto3D/src (2Dto3D is my project name) - 2Dto3D/gen - Android 4.2 - Android Dependencies
Should there maybe be something more there?
Under source tab, it says "Native library location: (None)". Sounds bad, doesn't it?
I have: Windows 7, 64 bit Have downloaded java JDK 7, 64 bit Eclipse for Mobile Developers Juno release 1 Try to run my code on a virtual device API 8
And my code (beginnings of a test calculation): (Sorry that the import block won't get into the code formatting here)
package com.mytest.threedee;
import com.mytest.threedee.R; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.widget.TextView; import static java.lang.Math.*;
public class MainActivity extends Activity {
static final double pixPerRad = 4850;
static final double center2Dhor = 276.6;
static final double center2Dver = 293.7;
static final double short2D = 426.3;
static final double long2D = 2719.3;
static final double tilt2D = -0.2557;
double minor, major, MSC, CSL; // angles
double CM, MS, ML, CL; // distances
double gQJ, gVQ, gQL, gHL, gVL, gMLV, gCLQ; // temporary guessing variables
double[] gCQ, gmajor; // guessing variables whose guess values will be stored
String[] gmajor_Text;
String[] gCQ_Text;
TextView text1 = null;
TextView text2 = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
text1 = (TextView)findViewById(R.id.textView1);
text2 = (TextView)findViewById(R.id.textView2);
minor = short2D/pixPerRad;
major = long2D/pixPerRad;
MS = 1/asin(minor);
ML = MS;
CM = sqrt(MS*MS - 1);
CL = MS - ML;
// Guessing triangle VQJ:
for (int i=0; i<2; i++)
{
gCQ[i] = i/3; // First two guesses
// Side QJ:
gQJ = sqrt(1 - gCQ[i]*gCQ[i]);
// Side VQ:
gQL = sqrt(CL*CL + gCQ[i]*gCQ[i]);
gCLQ = asin(gCQ[i]/gQL);
gMLV = gCLQ;
gHL = ML*cos(gMLV);
gVL = 2*gHL;
gVQ = gVL - gQL;
// major angle resulting from guess:
gmajor[i] = 2 * atan(gQJ/gVQ);
gmajor_Text[i] = String.valueOf(gmajor);
gCQ_Text[i] = String.valueOf(gCQ);
}//END for i
text1.setText(gmajor_Text[0]);
text2.setText(gCQ_Text[1]);
}//END onCreate
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}//END MainActivity