title: Android Program Crashing but no Obvious Error in Android Studio
body: <p>I've pasted some of my code below.  I'm trying to get this button to activate the calculation below and place the result in an EditText view.  I find no errors listed in the program, but it crashes on my Android phone when I press the button (calcbutton).  </p>
  
  <p>I'm wondering if there's a problem with my BigDecimal calculations, but I don't know why there isn't an error reported.</p>
  
  <pre><code>public String massVal;
  public String volVal;
  public String volunitdes;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_sfp);
  
  //declare ListView
      final ListView mass;
  
  //get ListView object from xml
      mass = (ListView) findViewById(R.id.mass);
  
  //defined array values to show in ListView
      String[] masslv = new String[]{"g", "mg", "µg", "mol", "mmol", "µmol"};
  
  //define new Adapter
      ArrayAdapter&lt;String&gt; massAdapter = new ArrayAdapter&lt;String&gt;
              (this, android.R.layout.simple_list_item_1, android.R.id.text1, masslv);
  
  //assign Adapter to ListView
      mass.setAdapter(massAdapter);
  
  //ListView Item Click Listener
      mass.setOnItemClickListener(new OnItemClickListener(){
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
          //ListView Clicked item index
          int itemPosition = position;
          //ListView Clicked item value
          String massVal = (String) mass.getItemAtPosition(position);
  
          //declare EditText for mass and place clicked value (String massVal) into box
              EditText masstext;
              masstext = (EditText) findViewById(R.id.masstext);
              masstext.setText(massVal);
          }});
  
  
  
  //button for final calculation
  Button calcbutton;
  calcbutton = (Button) findViewById(R.id.calcbutton);
  
  calcbutton.setOnClickListener(new View.OnClickListener(){
    public void onClick(View v) {
    //declare all manual number entries as EditText, then String, then BigDecimal
    EditText CONCdes = (EditText) findViewById(R.id.CONCdes);
    EditText voldes = (EditText) findViewById(R.id.voldes);
    EditText MWbox = (EditText) findViewById(R.id.MWbox);
  
    String CONCVAL = CONCdes.getText().toString();
    String VOLDES = voldes.getText().toString();
    String MW = MWbox.getText().toString();
  
    BigDecimal CONCVALbd = new BigDecimal(CONCVAL).setScale(2, RoundingMode.HALF_UP);
    BigDecimal VOLDESbd = new BigDecimal(VOLDES).setScale(2, RoundingMode.HALF_UP);
    BigDecimal MWbd = new BigDecimal(MW).setScale(2, RoundingMode.HALF_UP);
  
    //default calculation assumes ug/ml, ml vol units to measure, and mg units to weigh
  
    BigDecimal FINPOWDMEAS;
    FINPOWDMEAS = VOLDESbd.multiply(CONCVALbd).divide(BigDecimal.valueOf(1000)).setScale(2, RoundingMode.HALF_UP);
  
    if (massVal.equals("g"))
      {FINPOWDMEAS = FINPOWDMEAS.multiply(BigDecimal.valueOf(1000000)).setScale(2, RoundingMode.HALF_UP);}
  
    if (massVal.equals("mg"))
      {FINPOWDMEAS = FINPOWDMEAS.multiply(BigDecimal.valueOf(1000));}
  
    if (massVal.equals("mol"))
      {FINPOWDMEAS = VOLDESbd.multiply(CONCVALbd).multiply(MWbd).multiply(BigDecimal.valueOf(1000)).setScale(2, RoundingMode.HALF_UP);}
  
    if (massVal.equals("mmol"))
      {FINPOWDMEAS = (VOLDESbd.multiply(CONCVALbd).divide(BigDecimal.valueOf(1000))).multiply(MWbd).multiply(BigDecimal.valueOf(1000)).setScale(2, RoundingMode.HALF_UP);
  
    if (massVal.equals("µmol"))
      {FINPOWDMEAS = (VOLDESbd.multiply(CONCVALbd).divide(BigDecimal.valueOf(1000000))).multiply(MWbd).multiply(BigDecimal.valueOf(1000)).setScale(2, RoundingMode.HALF_UP);}
  
    if (volVal.equals("L"))
      {FINPOWDMEAS = FINPOWDMEAS.divide(BigDecimal.valueOf(1000)).setScale(2, RoundingMode.HALF_UP);}
  
    if (volVal.equals("dL"))
      {FINPOWDMEAS = FINPOWDMEAS.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP);}
  
    if (volVal.equals("µL")){FINPOWDMEAS = FINPOWDMEAS.multiply(BigDecimal.valueOf(1000)).setScale(2, RoundingMode.HALF_UP);}
  
    //final calculation value to string
    EditText FINPOWDMEASURE = (EditText) findViewById(R.id.FINPOWDMEASURE);
    String FINALPOWDERMEASURE = FINPOWDMEAS.toString();
    FINPOWDMEASURE.setText(FINALPOWDERMEASURE);}});
  </code></pre>
  
  <p>Exception:</p>
  
  <pre><code>Process: vanwert.sdb, PID: 907
  java.lang.NullPointerException
          at vanwert.sdb.SFP$4.onClick(SFP.java:134)
          at android.view.View.performClick(View.java:4438)
          at android.view.View$PerformClick.run(View.java:18422)
          at android.os.Handler.handleCallback(Handler.java:733)
          at android.os.Handler.dispatchMessage(Handler.java:95)
          at android.os.Looper.loop(Looper.java:136)
          at android.app.ActivityThread.main(ActivityThread.java:5017)
          at java.lang.reflect.Method.invokeNative(Native Method)
          at java.lang.reflect.Method.invoke(Method.java:515)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
          at dalvik.system.NativeStart.main(Native Method)
  </code></pre>