Monday, 15 April 2013

Android java.lang.NullPointer. Wrong path Eclipse Juno - JDK7? -



Android java.lang.NullPointer. Wrong path Eclipse Juno - JDK7? -

can't run little android code in eclipse, error message:

e/androidruntime(275): java.lang.runtimeexception: unable start activity componentinfo{com.mytest.threedee/com.mytest.threedee.mainactivity}: java.lang.nullpointerexception

what more info helpful? guess code irrelevent because eclipse fails start executing it. import java.lang.math.* why it's "nullpointer"? editor doesn't mark math functions error. suppose obscure path problem eclipse.

project/properties/order , export lists: - 2dto3d/src (2dto3d project name) - 2dto3d/gen - android 4.2 - android dependencies

should there maybe more there?

under source tab, says "native library location: (none)". sounds bad, doesn't it?

i have: windows 7, 64 bit have downloaded java jdk 7, 64 bit eclipse mobile developers juno release 1 seek run code on virtual device api 8

and code (beginnings of test calculation): (sorry import block won't 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 guess values 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: (int i=0; i<2; i++) { gcq[i] = i/3; // first 2 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 guess: gmajor[i] = 2 * atan(gqj/gvq); gmajor_text[i] = string.valueof(gmajor); gcq_text[i] = string.valueof(gcq); }//end text1.settext(gmajor_text[0]); text2.settext(gcq_text[1]); }//end oncreate @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.activity_main, menu); homecoming true; }

}//end mainactivity

you still haven't initialized arrays

double[] gcq; // later, utilize gcq[i] = i/3;

you should initialize either in oncreate() or outside

gcq = new double[size];

same goes both double[] , string[]

java android eclipse path

No comments:

Post a Comment