Solved

Java Error - Source Not found (Edit Source Lookup Path)

Posted on 2011-09-10
7
2,243 Views
Last Modified: 2012-05-12
Hello,

I'm new to Android development and I'm running into errors that I can't figure out when running the application. I'm getting Source Not found when running debug in eclipse.

Please help. I attached the code that I'm running.
package com.CSV.Buescher;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import android.util.Log;


public class OptionsPricingCalculatorActivity extends Activity {
    /** Called when the activity is first created. */
	Button myButton;
	TextView myStockPrice;
	TextView myExercise;
	TextView myDaysToExp;
	TextView myTreasuryReturn;
	TextView myVolatility;
	EditText myD1;
	EditText myD2;
	EditText myCallValue;
	EditText myPutValue;
	String sSP; //Stock Price String
	Double dSP; //Stock Price Double
	String sEX; //Exercise String
	Double dEX; //Exercise Double
	String sDTE; //Days To Expiration String
	Double dDTE; //Days To Expiration Double
	String sTR; //Treasury Return String
	Double dTR; //Treasury Return Double
	String sVL; //Volatility String
	Double dVL; //Volatility Double
	String sD1; //D1 String
	Double dD1; //D1 Double
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        myStockPrice = (TextView)findViewById(R.id.txtStockPrice);
        myExercise = (TextView)findViewById(R.id.txtExercise);
        myDaysToExp = (TextView)findViewById(R.id.txtDaysToExp);
        myTreasuryReturn = (TextView)findViewById(R.id.txtTreasuryReturn);
        myVolatility = (TextView)findViewById(R.id.txtVolatility);
        myD1 = (EditText)findViewById(R.id.lbld1);
        myD2 = (EditText)findViewById(R.id.lbld2);
        myCallValue = (EditText)findViewById(R.id.lblCallValue);
        myPutValue = (EditText)findViewById(R.id.lblPutValue);
        
        myButton.setOnClickListener(new View.OnClickListener(){
        	public void onClick(View v){
        		if (myStockPrice.getText().toString().equals("")){
        			Toast toast = Toast.makeText(getApplicationContext(), "Please enter a value for Stock Price.", Toast.LENGTH_LONG);
        			toast.show();
        		}
        		else if (myExercise.getText().toString().equals("")){
        			Toast toast = Toast.makeText(getApplicationContext(), "Please enter a value for Exercise Price.", Toast.LENGTH_LONG);
        			toast.show();
        		}
        		else if (myDaysToExp.getText().toString().equals("")){
        			Toast toast = Toast.makeText(getApplicationContext(), "Please enter a value for Days to Expiration.", Toast.LENGTH_LONG);
        			toast.show();
        		}
        		else if (myTreasuryReturn.getText().toString().equals("")){
        			Toast toast = Toast.makeText(getApplicationContext(), "Please enter a value for Treasury Return.", Toast.LENGTH_LONG);
        			toast.show();
        		}
        		else if (myVolatility.getText().toString().equals("")){
        			Toast toast = Toast.makeText(getApplicationContext(), "Please enter a value for Volatility.", Toast.LENGTH_LONG);
        			toast.show();
        		}
        		else{
        			sSP=myStockPrice.getText().toString();
        			dSP=Double.parseDouble(sSP);
        			sEX=myExercise.getText().toString();
        			dEX=Double.parseDouble(sEX);
        			sDTE=myDaysToExp.getText().toString();
        			dDTE=Double.parseDouble(sDTE);
        			sTR=myTreasuryReturn.getText().toString();
        			dTR=Double.parseDouble(sTR);
        			sVL=myVolatility.getText().toString();
        			dVL=Double.parseDouble(sVL);
        			
        			dD1 = ((Math.log(dSP/dEX)) + (dTR + 0.5*dVL*dVL)*(dDTE/365))/(dVL*(Math.sqrt(dDTE/365)));
        			sD1=Double.toString(dD1);
        			myD1.setText(sD1);
        		}
        	}

    		
        	});
    }
}


package com.CSV.Buescher;

import org.apache.commons.math.MathException;
import org.apache.commons.math.distribution.NormalDistributionImpl;

public class SDCalculator {
	 public Double Calc (Double a){
		 NormalDistributionImpl myND = new NormalDistributionImpl(); 
	        try {
				a = (myND.cumulativeProbability(a));
			} catch (MathException e) {
				// TODO Auto-generated catch block
				//e.printStackTrace();
			}
		return a;
		
	 }
}


//Main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:weightSum="1">
    <LinearLayout android:id="@+id/linearLayout1" android:layout_height="50dp" android:weightSum="1" android:layout_width="531dp">
       <TextView android:textAppearance="?android:attr/textAppearanceSmall" 
       			android:layout_height="wrap_content" 
       			android:text="Stock Price" 
       			android:lines="2" 
       			android:layout_width="57dp" 
       			android:gravity="center" 
       			android:id="@+id/lblStockPrice">
       </TextView>
       <TextView android:textAppearance="?android:attr/textAppearanceSmall" 
       			android:layout_height="wrap_content" 
       			android:text="Exercise or Strike Price" 
       			android:lines="2" 
       			android:layout_width="70dp" 
       			android:gravity="center" 
       			android:id="@+id/lblExercise">
       </TextView>
       <TextView android:textAppearance="?android:attr/textAppearanceSmall" 
       			android:layout_height="wrap_content" 
       			android:text="Days to Expiration" 
       			android:lines="2" 
       			android:layout_width="70dp" 
       			android:gravity="center" 
       			android:id="@+id/lblDaysToExp">
       </TextView>
       <TextView android:textAppearance="?android:attr/textAppearanceSmall" 
       			android:layout_height="wrap_content" 
       			android:text="Treasury Return" 
       			android:lines="2" 
       			android:layout_width="70dp" 
       			android:gravity="center" 
       			android:id="@+id/lblTreasuryReturn">
       </TextView>
       <TextView android:textAppearance="?android:attr/textAppearanceSmall" 
       			android:layout_height="wrap_content" 
       			android:text="Volatility (Std Dev)" 
       			android:lines="2" 
       			android:layout_width="70dp" 
       			android:gravity="center" 
       			android:id="@+id/lblVolatility">
       </TextView>
       <TextView android:textAppearance="?android:attr/textAppearanceSmall" 
       			android:layout_height="wrap_content" 
       			android:text="d1" 
       			android:lines="2" 
       			android:layout_width="40dp" 
       			android:gravity="center" 
       			android:id="@+id/lbld1">
       </TextView>
       <TextView android:textAppearance="?android:attr/textAppearanceSmall" 
       			android:layout_height="wrap_content" 
       			android:text="d2" 
       			android:lines="2" 
       			android:layout_width="40dp" 
       			android:gravity="center" 
       			android:id="@+id/lbld2">
       </TextView>
       <TextView android:textAppearance="?android:attr/textAppearanceSmall" 
       			android:layout_height="wrap_content" 
       			android:text="Call Value" 
       			android:lines="2" 
       			android:gravity="center"
       			android:layout_width="57dp" 
       			android:id="@+id/lblCallValue">
       </TextView>
       <TextView android:textAppearance="?android:attr/textAppearanceSmall" 
       			android:layout_height="wrap_content" 
       			android:text="Put Value" 
       			android:lines="2" 
       			android:gravity="center"
       			android:layout_width="57dp" 
       			android:id="@+id/lblPutValue">
       </TextView>
    </LinearLayout>
    <LinearLayout android:id="@+id/linearLayout2" android:layout_height="50dp" android:layout_width="531dp">
        <EditText android:layout_width="57dp" android:layout_height="wrap_content" android:inputType="numberDecimal" android:id="@+id/txtStockPrice"></EditText>
        <EditText android:layout_width="70dp" android:layout_height="wrap_content" android:inputType="numberDecimal" android:id="@+id/txtExercise"></EditText>
        <EditText android:layout_width="70dp" android:layout_height="wrap_content" android:inputType="numberDecimal" android:id="@+id/txtDaysToExp"></EditText>
        <EditText android:layout_width="70dp" android:layout_height="wrap_content" android:inputType="numberDecimal" android:id="@+id/txtTreasuryReturn"></EditText>
        <EditText android:layout_width="70dp" android:layout_height="wrap_content" android:inputType="numberDecimal" android:id="@+id/txtVolatility"></EditText>
        <TextView android:text="0.000" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceSmall" android:layout_width="40dp" android:gravity="center" android:id="@+id/txtD1"></TextView>
        <TextView android:text="0.000" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceSmall" android:layout_width="40dp" android:gravity="center" android:id="@+id/txtD2"></TextView>
        <TextView android:text="0.000" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceSmall" android:layout_width="57dp" android:gravity="center" android:id="@+id/txtCallValue"></TextView>
        <TextView android:text="0.000" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceSmall" android:layout_width="57dp" android:gravity="center" android:id="@+id/txtPutValue"></TextView>
    </LinearLayout>
    <Button android:layout_width="wrap_content" android:id="@+id/btnCalculate" android:layout_height="wrap_content" android:text="Calculate"></Button>
</LinearLayout>


//strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="hello">Hello World, OptionsPricingCalculatorActivity!</string>
    <string name="app_name">OptionsPricingCalculator</string>
</resources>


//manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.CSV.Buescher"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="8" />

    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".OptionsPricingCalculatorActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
</manifest>


debug errors are

<terminated>OptionsPricingCalculator [Android Application]	
	<disconnected>DalvikVM[localhost:8637]	
OptionsPricingCalculator [Android Application]	
	DalvikVM[localhost:8637]	
		Thread [<1> main] (Suspended (exception RuntimeException))	
			ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2663	
			ActivityThread.handleLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2679	
			ActivityThread.access$2300(ActivityThread, ActivityThread$ActivityRecord, Intent) line: 125	
			ActivityThread$H.handleMessage(Message) line: 2033	
			ActivityThread$H(Handler).dispatchMessage(Message) line: 99	
			Looper.loop() line: 123	
			ActivityThread.main(String[]) line: 4627	
			Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]	
			Method.invoke(Object, Object...) line: 521	
			ZygoteInit$MethodAndArgsCaller.run() line: 868	
			ZygoteInit.main(String[]) line: 626	
			NativeStart.main(String[]) line: not available [native method]	
		Thread [<6> Binder Thread #2] (Running)	
		Thread [<5> Binder Thread #1] (Running)

Open in new window

0
Comment
Question by:lulubell-b
  • 4
  • 2
7 Comments
 
LVL 5

Expert Comment

by:Rinil
ID: 36518698
hi,

It might be due to the fact that the android source code is not involved with android API, so while debugging that will take the control to any android class then the eclipse will throw error


http://android.opensourceror.org/2010/01/18/android-source/

below link helps in attaching the source with eclipse platform

please check it out
0
 

Author Comment

by:lulubell-b
ID: 36519277
Ok, now I'm able to see the source code. I get the following error on the first line

ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2663      


Unsure how to fix?
catch (Exception e) {
            if (!mInstrumentation.onException(activity, e)) {
                throw new RuntimeException(
                    "Unable to start activity " + component
                    + ": " + e.toString(), e);
            }
        }

Open in new window

0
 

Author Comment

by:lulubell-b
ID: 36519278
Also found this in trace


09-11 16:30:50.218: ERROR/AndroidRuntime(394): Caused by: java.lang.ClassCastException: android.widget.TextView
09-11 16:30:50.218: ERROR/AndroidRuntime(394):     at com.CSV.Buescher.OptionsPricingCalculatorActivity.onCreate(OptionsPricingCalculatorActivity.java:47)
09-11 16:30:50.218: ERROR/AndroidRuntime(394):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-11 16:30:50.218: ERROR/AndroidRuntime(394):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
09-11 16:30:50.218: ERROR/AndroidRuntime(394):     ... 11 more
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 9

Expert Comment

by:arioh
ID: 36519397
According to Main.xml variables declaration should be as follows:
EditText myStockPrice;
EditText myExercise;
EditText myDaysToExp;
EditText myTreasuryReturn;
EditText myVolatility;
TextView myD1;
TextView myD2;
TextView myCallValue;
TextView myPutValue;

.................

myStockPrice = (EditText)findViewById(R.id.txtStockPrice);
myExercise = (EditText)findViewById(R.id.txtExercise);
myDaysToExp = (EditText)findViewById(R.id.txtDaysToExp);
myTreasuryReturn = (EditText)findViewById(R.id.txtTreasuryReturn);
myVolatility = (EditText)findViewById(R.id.txtVolatility);
myD1 = (TextView)findViewById(R.id.lbld1);
myD2 = (TextView)findViewById(R.id.lbld2);
myCallValue = (TextView)findViewById(R.id.lblCallValue);
myPutValue = (TextView)findViewById(R.id.lblPutValue);

Open in new window

0
 

Author Comment

by:lulubell-b
ID: 36520546
I'm confused. Did I just have them in the wrong order or did I call something a wrong type?

ok, now I get ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2663      
 and the trace says the following:

09-12 01:49:33.918: ERROR/AndroidRuntime(445): Caused by: java.lang.NullPointerException
09-12 01:49:33.918: ERROR/AndroidRuntime(445):     at com.CSV.Buescher.OptionsPricingCalculatorActivity.onCreate(OptionsPricingCalculatorActivity.java:52)
09-12 01:49:33.918: ERROR/AndroidRuntime(445):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-12 01:49:33.918: ERROR/AndroidRuntime(445):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
09-12 01:49:33.918: ERROR/AndroidRuntime(445):     ... 11 more


Again, I'm new to android development and I have no clue on this error.

Thanks
0
 
LVL 9

Accepted Solution

by:
arioh earned 500 total points
ID: 36521924
For example

Main.xml:
  <EditText android:layout_width="70dp" android:layout_height="wrap_content" android:inputType="numberDecimal" android:id="@+id/txtVolatility"></EditText>

your code:
TextView myVolatility;
myVolatility = (TextView)findViewById(R.id.txtVolatility);

should be:
EditText myVolatility;
myVolatility = (EditText)findViewById(R.id.txtVolatility);

So, myVolatility is not TextView, it is EditText.
0
 

Author Comment

by:lulubell-b
ID: 36526957
Perfect, Thank you I got it to work.
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to convert String matching to regex in java 4 51
null output 3 35
Problem to Alipay 10 47
Bot application - advice 3 39
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question