Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8316269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:19:28+00:00 2026-06-08T21:19:28+00:00

here is the java file, the only one used…If i knew what the errors

  • 0

here is the java file, the only one used…If i knew what the errors meant i could do this myself

package tip.calculator;


import android.os.Bundle;
import android.app.Activity;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.TextView;
import android.view.View;
import android.widget.Button;




public class TipCalculator extends Activity 
{

private Button enter;
EditText myEditField = (EditText) findViewById(R.id.percentText);
final EditText myEditField2 = (EditText) findViewById(R.id.billText);

float percentage = 0;
float percentageInp = 0;
float billAmount = 0;
double output = 0; 
String output1 = "";
Button clearButton = (Button) findViewById(R.id.clearButton);

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    myEditField = (EditText) findViewById(R.id.percentText);
    enter = (Button)findViewById(R.id.button1);


    enter.setOnClickListener(new OnClickListener() {


        public void onClick(View v) {
             TextView textView;
             TextView errors;
             textView = (TextView) findViewById(R.id.textView1);
             errors = (TextView) findViewById(R.id.errorText);             
             for(;;){

             if(myEditField == null){
                 break;
             }

             if(myEditField2 == null){
                 break;
             }

             }

            percentageInp = Float.parseFloat(myEditField.getText().toString());
            billAmount = Float.parseFloat(myEditField2.getText().toString());

            percentage = ((float)percentageInp /100);

            output = (double)(billAmount * percentage);

            double result = output * 100;
            result = Math.round(result);
            result = result / 100;

            output1 = Double.toString(result);

            textView.setText(output1 + " $");

        }
    });

    clearButton.setOnClickListener(new OnClickListener() {

        public void onClick(View arg0) {

            percentage = 0;
            output = 0;
            output1 = "";
             TextView textView;

             textView = (TextView) findViewById(R.id.textView1);

            textView.setText("");

            percentageInp = 0;
            billAmount = 0;

            myEditField.setText("");
            myEditField2.setText("");


        }


    });
}
}

This is the logcat, i don’t know what the errors mean or how to approach them… Note: These are only produced when the app is opened, and then it crashes

08-01 15:37:43.934: E/Trace(671): error opening trace file: No such file or directory (2)
08-01 15:37:44.704: E/AndroidRuntime(671): FATAL EXCEPTION: main
08-01 15:37:44.704: E/AndroidRuntime(671): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{tip.calculator/tip.calculator.TipCalculator}: java.lang.NullPointerException
08-01 15:37:44.704: E/AndroidRuntime(671):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
08-01 15:37:44.704: E/AndroidRuntime(671):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
08-01 15:37:44.704: E/AndroidRuntime(671):  at android.app.ActivityThread.access$600(ActivityThread.java:130)
08-01 15:37:44.704: E/AndroidRuntime(671):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
08-01 15:37:44.704: E/AndroidRuntime(671):  at android.os.Handler.dispatchMessage(Handler.java:99)
08-01 15:37:44.704: E/AndroidRuntime(671):  at android.os.Looper.loop(Looper.java:137)
08-01 15:37:44.704: E/AndroidRuntime(671):  at android.app.ActivityThread.main(ActivityThread.java:4745)
08-01 15:37:44.704: E/AndroidRuntime(671):  at java.lang.reflect.Method.invokeNative(Native Method)
08-01 15:37:44.704: E/AndroidRuntime(671):  at java.lang.reflect.Method.invoke(Method.java:511)
08-01 15:37:44.704: E/AndroidRuntime(671):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
08-01 15:37:44.704: E/AndroidRuntime(671):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-01 15:37:44.704: E/AndroidRuntime(671):  at dalvik.system.NativeStart.main(Native Method)
08-01 15:37:44.704: E/AndroidRuntime(671): Caused by: java.lang.NullPointerException
08-01 15:37:44.704: E/AndroidRuntime(671):  at android.app.Activity.findViewById(Activity.java:1825)
08-01 15:37:44.704: E/AndroidRuntime(671):  at tip.calculator.TipCalculator.<init>(TipCalculator.java:19)
08-01 15:37:44.704: E/AndroidRuntime(671):  at java.lang.Class.newInstanceImpl(Native Method)
08-01 15:37:44.704: E/AndroidRuntime(671):  at java.lang.Class.newInstance(Class.java:1319)
08-01 15:37:44.704: E/AndroidRuntime(671):  at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
08-01 15:37:44.704: E/AndroidRuntime(671):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
08-01 15:37:44.704: E/AndroidRuntime(671):  ... 11 more
08-01 15:38:44.993: E/Trace(741): error opening trace file: No such file or directory (2)
08-01 15:38:45.123: E/AndroidRuntime(741): FATAL EXCEPTION: main
08-01 15:38:45.123: E/AndroidRuntime(741): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{tip.calculator/tip.calculator.TipCalculator}: java.lang.NullPointerException
08-01 15:38:45.123: E/AndroidRuntime(741):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
08-01 15:38:45.123: E/AndroidRuntime(741):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
08-01 15:38:45.123: E/AndroidRuntime(741):  at android.app.ActivityThread.access$600(ActivityThread.java:130)
08-01 15:38:45.123: E/AndroidRuntime(741):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
08-01 15:38:45.123: E/AndroidRuntime(741):  at android.os.Handler.dispatchMessage(Handler.java:99)
08-01 15:38:45.123: E/AndroidRuntime(741):  at android.os.Looper.loop(Looper.java:137)
08-01 15:38:45.123: E/AndroidRuntime(741):  at android.app.ActivityThread.main(ActivityThread.java:4745)
08-01 15:38:45.123: E/AndroidRuntime(741):  at java.lang.reflect.Method.invokeNative(Native Method)
08-01 15:38:45.123: E/AndroidRuntime(741):  at java.lang.reflect.Method.invoke(Method.java:511)
08-01 15:38:45.123: E/AndroidRuntime(741):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
08-01 15:38:45.123: E/AndroidRuntime(741):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-01 15:38:45.123: E/AndroidRuntime(741):  at dalvik.system.NativeStart.main(Native Method)
08-01 15:38:45.123: E/AndroidRuntime(741): Caused by: java.lang.NullPointerException
08-01 15:38:45.123: E/AndroidRuntime(741):  at android.app.Activity.findViewById(Activity.java:1825)
08-01 15:38:45.123: E/AndroidRuntime(741):  at tip.calculator.TipCalculator.<init>(TipCalculator.java:19)
08-01 15:38:45.123: E/AndroidRuntime(741):  at java.lang.Class.newInstanceImpl(Native Method)
08-01 15:38:45.123: E/AndroidRuntime(741):  at java.lang.Class.newInstance(Class.java:1319)
08-01 15:38:45.123: E/AndroidRuntime(741):  at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
08-01 15:38:45.123: E/AndroidRuntime(741):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
08-01 15:38:45.123: E/AndroidRuntime(741):  ... 11 more
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T21:19:29+00:00Added an answer on June 8, 2026 at 9:19 pm

    The problem is these lines that you are using to initialize member fields of your TipCalculator class:

    EditText myEditField = (EditText) findViewById(R.id.percentText);
    final EditText myEditField2 = (EditText) findViewById(R.id.billText);
    Button clearButton = (Button) findViewById(R.id.clearButton);
    

    You cannot use findViewById before you have called setContentView. Replace the above with:

    EditText myEditField;
    EditText myEditField2;
    Button clearButton;
    

    And then add this to onCreate somewhere after calling setContentView:

    myEditField = (EditText) findViewById(R.id.percentText);
    myEditField2 = (EditText) findViewById(R.id.billText);
    clearButton = (Button) findViewById(R.id.clearButton);
    

    P.S. The way to interpret the logcat output is to look for the last “Caused by:” line and read that stack trace. All the ones before it are irrelevant for this kind of diagnosis task.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's the class package db; import java.io.File; import java.io.FileInputStream; import java.sql.Connection; import java.sql.DriverManager; import
I am trying got use spring-mvc tag inside java-script file, here is what i
Referring here A is a precompiled Java class (I also have the source file)
For example I have a file name call A.java. Here its structure: public class
I'm programming Java in Eclipse IDE. Here is code I want to read file:
To use a contrived example in Java, here's the code: enum Commands{ Save(S); File(F);
I have this chess engine Rybka.exe, that i have to execute in java Here
I'm using Java 5 javax.xml.validation.Validator to validate XML file. I've done it for one
I have file TestClass.java package com.fido.android.sample.dsm.SoftPin.Core; public class TestClass { public int mValue1; public
I have some confusions on java file lock. here's my situation. Each thread can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.