我的应用程序在我的 AVD 上启动时立即崩溃
My Application crashes immediately on launch on my AVD
我一直在 android 尝试处理此税务申请,但它因我无法理解的错误而崩溃。我想就此获得帮助,因为我之前的回答无法阻止崩溃。非常感谢您的时间和帮助。
我的Activity在这里
包裹 com.example.lorlormensah.taxapp;
import android.app.ActionBar;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
public class MainActivity extends AppCompatActivity implements View.OnClickListener{
double realSalary, taxPayable, sniit,firstTax,taxes, levelTax,taxable;
EditText payable;
Button calculate;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
EditText salary = (EditText) findViewById(R.id.edit_salary);
EditText allowance = (EditText) findViewById(R.id.edit_allowance);
EditText incomeTax = (EditText) findViewById(R.id.IncTax_edit);
EditText payable = (EditText) findViewById(R.id.payable_edit);
EditText totalTax = (EditText) findViewById(R.id.deduction_edit);
Button calculate = (Button) findViewById(R.id.calculate_button);
double realSalary = Double.parseDouble(salary.getText().toString());
double realAllowance = Double.parseDouble(allowance.getText().toString());
}
// final double taxRate = 0.055;
// double tax;
@Override
public void onClick (View v) {
calculate.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
getSnit();
getTaxable();
computeTaxes();
}
// }
public double getSnit() {
sniit = realSalary * 0.055;
return sniit;
}
// CALCULATING THE TAXABLE AFTER SNIIT
public double getTaxable() {
if (realSalary <= 216) {
} else {
taxable = realSalary - sniit;
}
return taxable;
}
public double computeTaxes() {
//SOLVING FOR THE SECOND LEVEL(2ND) LEVEL
if (taxable > 216 && taxable <= 324) {
levelTax = taxable - 216;
firstTax = levelTax * 0.05;
System.out.println(levelTax);
taxes = 0.0 + firstTax;
payable.setText("" + taxes);
//SOLVING FOR THE THIRD(3RD) LEVEL
} else if (taxable > 324 && taxable <= 475) {
levelTax = taxable - (216 + 108);
firstTax = levelTax * 0.10;
System.out.println(levelTax);
taxes = 0 + 5.40 + firstTax;
payable.setText("" + taxes);
//SOLVING FOR THE FOURTH(4TH) LEVEL
} else if (taxable > 324 && taxable <= 3240) {
levelTax = taxable - (216 + 108 + 151);
firstTax = levelTax * 0.175;
System.out.println(levelTax);
taxes = 0 + 5.40 + 15.10 + firstTax;
payable.setText("" + taxes);
//SOLVING FOR THE FIFTH(5TH) LEVEL
} else if (taxable > 3240) {
levelTax = taxable - (216 + 108 + 151 + 2765);
firstTax = levelTax * 0.25;
//System.out.println("First tax2 " + levelTax);
taxes = 0 + 5.40 + 15.10 + 483.88 + firstTax;
payable.setText("" + taxes);
}
return taxes;
}
});
}
}
My Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.lorlormensah.taxapp">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
My errors
02-26 19:59:33.727 848-848/? W/dalvikvm: PR_CAPBSET_DROP 0 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.767 848-848/? W/dalvikvm: PR_CAPBSET_DROP 1 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.767 848-848/? W/dalvikvm: PR_CAPBSET_DROP 2 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.767 848-848/? W/dalvikvm: PR_CAPBSET_DROP 3 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.767 848-848/? W/dalvikvm: PR_CAPBSET_DROP 4 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.777 848-848/? W/dalvikvm: PR_CAPBSET_DROP 5 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.777 848-848/? W/dalvikvm: PR_CAPBSET_DROP 6 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.786 848-848/? W/dalvikvm: PR_CAPBSET_DROP 7 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.786 848-848/? W/dalvikvm: PR_CAPBSET_DROP 8 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.786 848-848/? W/dalvikvm: PR_CAPBSET_DROP 9 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.786 848-848/? W/dalvikvm: PR_CAPBSET_DROP 10 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.786 848-848/? W/dalvikvm: PR_CAPBSET_DROP 11 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.786 848-848/? W/dalvikvm: PR_CAPBSET_DROP 12 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.786 848-848/? W/dalvikvm: PR_CAPBSET_DROP 13 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.796 848-848/? W/dalvikvm: PR_CAPBSET_DROP 14 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.796 848-848/? W/dalvikvm: PR_CAPBSET_DROP 15 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.796 848-848/? W/dalvikvm: PR_CAPBSET_DROP 16 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.796 848-848/? W/dalvikvm: PR_CAPBSET_DROP 17 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.796 848-848/? W/dalvikvm: PR_CAPBSET_DROP 18 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.796 848-848/? W/dalvikvm: PR_CAPBSET_DROP 19 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.796 848-848/? W/dalvikvm: PR_CAPBSET_DROP 20 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.796 848-848/? W/dalvikvm: PR_CAPBSET_DROP 21 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.796 848-848/? W/dalvikvm: PR_CAPBSET_DROP 22 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.806 848-848/? W/dalvikvm: PR_CAPBSET_DROP 23 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.806 848-848/? W/dalvikvm: PR_CAPBSET_DROP 24 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.806 848-848/? W/dalvikvm: PR_CAPBSET_DROP 25 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.806 848-848/? W/dalvikvm: PR_CAPBSET_DROP 26 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.806 848-848/? W/dalvikvm: PR_CAPBSET_DROP 27 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.806 848-848/? W/dalvikvm: PR_CAPBSET_DROP 28 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.806 848-848/? W/dalvikvm: PR_CAPBSET_DROP 29 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.806 848-848/? W/dalvikvm: PR_CAPBSET_DROP 30 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.806 848-848/? W/dalvikvm: PR_CAPBSET_DROP 31 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.806 848-848/? W/dalvikvm: PR_CAPBSET_DROP 32 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.806 848-848/? W/dalvikvm: PR_CAPBSET_DROP 33 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.816 848-848/? D/dalvikvm: Not late-enabling CheckJNI (already on)
02-26 19:59:36.156 848-848/com.example.lorlormensah.taxapp W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/view/SearchEvent;)
02-26 19:59:36.156 848-848/com.example.lorlormensah.taxapp I/dalvikvm: Could not find method android.view.Window$Callback.onSearchRequested, referenced from method android.support.v7.view.WindowCallbackWrapper.onSearchRequested
02-26 19:59:36.156 848-848/com.example.lorlormensah.taxapp W/dalvikvm: VFY: unable to resolve interface method 17961: Landroid/view/Window$Callback;.onSearchRequested (Landroid/view/SearchEvent;)Z
02-26 19:59:36.166 848-848/com.example.lorlormensah.taxapp D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
02-26 19:59:36.196 848-848/com.example.lorlormensah.taxapp I/dalvikvm: Could not find method android.view.Window$Callback.onWindowStartingActionMode, referenced from method android.support.v7.view.WindowCallbackWrapper.onWindowStartingActionMode
02-26 19:59:36.196 848-848/com.example.lorlormensah.taxapp W/dalvikvm: VFY: unable to resolve interface method 17965: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
02-26 19:59:36.196 848-848/com.example.lorlormensah.taxapp D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
02-26 19:59:36.896 848-848/com.example.lorlormensah.taxapp I/dalvikvm: Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.widget.TintTypedArray.getChangingConfigurations
02-26 19:59:36.896 848-848/com.example.lorlormensah.taxapp W/dalvikvm: VFY: unable to resolve virtual method 421: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
02-26 19:59:36.896 848-848/com.example.lorlormensah.taxapp D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
02-26 19:59:36.937 848-848/com.example.lorlormensah.taxapp I/dalvikvm: Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.widget.TintTypedArray.getType
02-26 19:59:36.947 848-848/com.example.lorlormensah.taxapp W/dalvikvm: VFY: unable to resolve virtual method 443: Landroid/content/res/TypedArray;.getType (I)I
02-26 19:59:36.947 848-848/com.example.lorlormensah.taxapp D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
02-26 19:59:37.006 848-848/com.example.lorlormensah.taxapp I/dalvikvm: Could not find method android.widget.LinearLayout$LayoutParams.<init>, referenced from method android.support.design.widget.AppBarLayout$LayoutParams.<init>
02-26 19:59:37.006 848-848/com.example.lorlormensah.taxapp W/dalvikvm: VFY: unable to resolve direct method 18478: Landroid/widget/LinearLayout$LayoutParams;.<init> (Landroid/widget/LinearLayout$LayoutParams;)V
02-26 19:59:37.006 848-848/com.example.lorlormensah.taxapp D/dalvikvm: VFY: replacing opcode 0x70 at 0x0000
02-26 19:59:37.026 848-848/com.example.lorlormensah.taxapp I/dalvikvm: Could not find method android.widget.LinearLayout$LayoutParams.<init>, referenced from method android.support.design.widget.AppBarLayout$LayoutParams.<init>
02-26 19:59:37.026 848-848/com.example.lorlormensah.taxapp W/dalvikvm: VFY: unable to resolve direct method 18478: Landroid/widget/LinearLayout$LayoutParams;.<init> (Landroid/widget/LinearLayout$LayoutParams;)V
02-26 19:59:37.026 848-848/com.example.lorlormensah.taxapp D/dalvikvm: VFY: replacing opcode 0x70 at 0x0000
02-26 19:59:37.166 848-848/com.example.lorlormensah.taxapp I/dalvikvm: Could not find method android.content.res.Resources.getDrawable, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawable
02-26 19:59:37.176 848-848/com.example.lorlormensah.taxapp W/dalvikvm: VFY: unable to resolve virtual method 384: Landroid/content/res/Resources;.getDrawable (ILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
02-26 19:59:37.176 848-848/com.example.lorlormensah.taxapp D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
02-26 19:59:37.197 848-848/com.example.lorlormensah.taxapp I/dalvikvm: Could not find method android.content.res.Resources.getDrawableForDensity, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawableForDensity
02-26 19:59:37.197 848-848/com.example.lorlormensah.taxapp W/dalvikvm: VFY: unable to resolve virtual method 386: Landroid/content/res/Resources;.getDrawableForDensity (IILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
02-26 19:59:37.216 848-848/com.example.lorlormensah.taxapp D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
02-26 19:59:37.776 848-848/com.example.lorlormensah.taxapp D/dalvikvm: GC_FOR_ALLOC freed 150K, 10% free 2716K/2992K, paused 97ms, total 106ms
02-26 19:59:37.806 848-848/com.example.lorlormensah.taxapp I/dalvikvm-heap: Grow heap (frag case) to 3.377MB for 635812-byte allocation
02-26 19:59:37.907 848-857/com.example.lorlormensah.taxapp D/dalvikvm: GC_FOR_ALLOC freed 2K, 8% free 3334K/3616K, paused 98ms, total 99ms
02-26 19:59:38.646 848-848/com.example.lorlormensah.taxapp D/AndroidRuntime: Shutting down VM
02-26 19:59:38.646 848-848/com.example.lorlormensah.taxapp W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x41465730)
02-26 19:59:39.016 848-848/com.example.lorlormensah.taxapp E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.lorlormensah.taxapp/com.example.lorlormensah.taxapp.MainActivity}: java.lang.NumberFormatException: Invalid double: ""
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access0(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NumberFormatException: Invalid double: ""
at java.lang.StringToReal.invalidReal(StringToReal.java:63)
at java.lang.StringToReal.parseDouble(StringToReal.java:248)
at java.lang.Double.parseDouble(Double.java:295)
at com.example.lorlormensah.taxapp.MainActivity.onCreate(MainActivity.java:36)
at android.app.Activity.performCreate(Activity.java:5133)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access0(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
02-26 20:04:39.726 848-848/com.example.lorlormensah.taxapp I/Process: Sending signal. PID: 848 SIG: 9
realSalary 和 realAllowance 双精度值导致崩溃,请检查它们是否为空
尝试以下操作:
EditText payable;
Button calculate;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
EditText salary = (EditText) findViewById(R.id.edit_salary);
EditText allowance = (EditText) findViewById(R.id.edit_allowance);
EditText incomeTax = (EditText) findViewById(R.id.IncTax_edit);
EditText payable = (EditText) findViewById(R.id.payable_edit);
EditText totalTax = (EditText) findViewById(R.id.deduction_edit);
Button calculate = (Button) findViewById(R.id.calculate_button);
if(salary.getText().toString().length()>0)
{
double realSalary=Double.parseDouble(salary.getText().toString());
}
if(allowance.getText().toString().length()>0)
{
double realAllowance = Double.parseDouble(allowance.getText().toString());
}
我一直在 android 尝试处理此税务申请,但它因我无法理解的错误而崩溃。我想就此获得帮助,因为我之前的回答无法阻止崩溃。非常感谢您的时间和帮助。
我的Activity在这里 包裹 com.example.lorlormensah.taxapp;
import android.app.ActionBar;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
public class MainActivity extends AppCompatActivity implements View.OnClickListener{
double realSalary, taxPayable, sniit,firstTax,taxes, levelTax,taxable;
EditText payable;
Button calculate;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
EditText salary = (EditText) findViewById(R.id.edit_salary);
EditText allowance = (EditText) findViewById(R.id.edit_allowance);
EditText incomeTax = (EditText) findViewById(R.id.IncTax_edit);
EditText payable = (EditText) findViewById(R.id.payable_edit);
EditText totalTax = (EditText) findViewById(R.id.deduction_edit);
Button calculate = (Button) findViewById(R.id.calculate_button);
double realSalary = Double.parseDouble(salary.getText().toString());
double realAllowance = Double.parseDouble(allowance.getText().toString());
}
// final double taxRate = 0.055;
// double tax;
@Override
public void onClick (View v) {
calculate.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
getSnit();
getTaxable();
computeTaxes();
}
// }
public double getSnit() {
sniit = realSalary * 0.055;
return sniit;
}
// CALCULATING THE TAXABLE AFTER SNIIT
public double getTaxable() {
if (realSalary <= 216) {
} else {
taxable = realSalary - sniit;
}
return taxable;
}
public double computeTaxes() {
//SOLVING FOR THE SECOND LEVEL(2ND) LEVEL
if (taxable > 216 && taxable <= 324) {
levelTax = taxable - 216;
firstTax = levelTax * 0.05;
System.out.println(levelTax);
taxes = 0.0 + firstTax;
payable.setText("" + taxes);
//SOLVING FOR THE THIRD(3RD) LEVEL
} else if (taxable > 324 && taxable <= 475) {
levelTax = taxable - (216 + 108);
firstTax = levelTax * 0.10;
System.out.println(levelTax);
taxes = 0 + 5.40 + firstTax;
payable.setText("" + taxes);
//SOLVING FOR THE FOURTH(4TH) LEVEL
} else if (taxable > 324 && taxable <= 3240) {
levelTax = taxable - (216 + 108 + 151);
firstTax = levelTax * 0.175;
System.out.println(levelTax);
taxes = 0 + 5.40 + 15.10 + firstTax;
payable.setText("" + taxes);
//SOLVING FOR THE FIFTH(5TH) LEVEL
} else if (taxable > 3240) {
levelTax = taxable - (216 + 108 + 151 + 2765);
firstTax = levelTax * 0.25;
//System.out.println("First tax2 " + levelTax);
taxes = 0 + 5.40 + 15.10 + 483.88 + firstTax;
payable.setText("" + taxes);
}
return taxes;
}
});
}
}
My Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.lorlormensah.taxapp">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
My errors
02-26 19:59:33.727 848-848/? W/dalvikvm: PR_CAPBSET_DROP 0 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.767 848-848/? W/dalvikvm: PR_CAPBSET_DROP 1 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.767 848-848/? W/dalvikvm: PR_CAPBSET_DROP 2 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.767 848-848/? W/dalvikvm: PR_CAPBSET_DROP 3 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.767 848-848/? W/dalvikvm: PR_CAPBSET_DROP 4 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.777 848-848/? W/dalvikvm: PR_CAPBSET_DROP 5 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.777 848-848/? W/dalvikvm: PR_CAPBSET_DROP 6 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.786 848-848/? W/dalvikvm: PR_CAPBSET_DROP 7 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.786 848-848/? W/dalvikvm: PR_CAPBSET_DROP 8 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.786 848-848/? W/dalvikvm: PR_CAPBSET_DROP 9 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.786 848-848/? W/dalvikvm: PR_CAPBSET_DROP 10 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.786 848-848/? W/dalvikvm: PR_CAPBSET_DROP 11 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.786 848-848/? W/dalvikvm: PR_CAPBSET_DROP 12 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.786 848-848/? W/dalvikvm: PR_CAPBSET_DROP 13 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.796 848-848/? W/dalvikvm: PR_CAPBSET_DROP 14 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.796 848-848/? W/dalvikvm: PR_CAPBSET_DROP 15 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.796 848-848/? W/dalvikvm: PR_CAPBSET_DROP 16 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.796 848-848/? W/dalvikvm: PR_CAPBSET_DROP 17 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.796 848-848/? W/dalvikvm: PR_CAPBSET_DROP 18 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.796 848-848/? W/dalvikvm: PR_CAPBSET_DROP 19 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.796 848-848/? W/dalvikvm: PR_CAPBSET_DROP 20 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.796 848-848/? W/dalvikvm: PR_CAPBSET_DROP 21 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.796 848-848/? W/dalvikvm: PR_CAPBSET_DROP 22 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.806 848-848/? W/dalvikvm: PR_CAPBSET_DROP 23 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.806 848-848/? W/dalvikvm: PR_CAPBSET_DROP 24 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.806 848-848/? W/dalvikvm: PR_CAPBSET_DROP 25 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.806 848-848/? W/dalvikvm: PR_CAPBSET_DROP 26 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.806 848-848/? W/dalvikvm: PR_CAPBSET_DROP 27 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.806 848-848/? W/dalvikvm: PR_CAPBSET_DROP 28 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.806 848-848/? W/dalvikvm: PR_CAPBSET_DROP 29 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.806 848-848/? W/dalvikvm: PR_CAPBSET_DROP 30 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.806 848-848/? W/dalvikvm: PR_CAPBSET_DROP 31 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.806 848-848/? W/dalvikvm: PR_CAPBSET_DROP 32 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.806 848-848/? W/dalvikvm: PR_CAPBSET_DROP 33 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
02-26 19:59:33.816 848-848/? D/dalvikvm: Not late-enabling CheckJNI (already on)
02-26 19:59:36.156 848-848/com.example.lorlormensah.taxapp W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/view/SearchEvent;)
02-26 19:59:36.156 848-848/com.example.lorlormensah.taxapp I/dalvikvm: Could not find method android.view.Window$Callback.onSearchRequested, referenced from method android.support.v7.view.WindowCallbackWrapper.onSearchRequested
02-26 19:59:36.156 848-848/com.example.lorlormensah.taxapp W/dalvikvm: VFY: unable to resolve interface method 17961: Landroid/view/Window$Callback;.onSearchRequested (Landroid/view/SearchEvent;)Z
02-26 19:59:36.166 848-848/com.example.lorlormensah.taxapp D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
02-26 19:59:36.196 848-848/com.example.lorlormensah.taxapp I/dalvikvm: Could not find method android.view.Window$Callback.onWindowStartingActionMode, referenced from method android.support.v7.view.WindowCallbackWrapper.onWindowStartingActionMode
02-26 19:59:36.196 848-848/com.example.lorlormensah.taxapp W/dalvikvm: VFY: unable to resolve interface method 17965: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
02-26 19:59:36.196 848-848/com.example.lorlormensah.taxapp D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
02-26 19:59:36.896 848-848/com.example.lorlormensah.taxapp I/dalvikvm: Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.widget.TintTypedArray.getChangingConfigurations
02-26 19:59:36.896 848-848/com.example.lorlormensah.taxapp W/dalvikvm: VFY: unable to resolve virtual method 421: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
02-26 19:59:36.896 848-848/com.example.lorlormensah.taxapp D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
02-26 19:59:36.937 848-848/com.example.lorlormensah.taxapp I/dalvikvm: Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.widget.TintTypedArray.getType
02-26 19:59:36.947 848-848/com.example.lorlormensah.taxapp W/dalvikvm: VFY: unable to resolve virtual method 443: Landroid/content/res/TypedArray;.getType (I)I
02-26 19:59:36.947 848-848/com.example.lorlormensah.taxapp D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
02-26 19:59:37.006 848-848/com.example.lorlormensah.taxapp I/dalvikvm: Could not find method android.widget.LinearLayout$LayoutParams.<init>, referenced from method android.support.design.widget.AppBarLayout$LayoutParams.<init>
02-26 19:59:37.006 848-848/com.example.lorlormensah.taxapp W/dalvikvm: VFY: unable to resolve direct method 18478: Landroid/widget/LinearLayout$LayoutParams;.<init> (Landroid/widget/LinearLayout$LayoutParams;)V
02-26 19:59:37.006 848-848/com.example.lorlormensah.taxapp D/dalvikvm: VFY: replacing opcode 0x70 at 0x0000
02-26 19:59:37.026 848-848/com.example.lorlormensah.taxapp I/dalvikvm: Could not find method android.widget.LinearLayout$LayoutParams.<init>, referenced from method android.support.design.widget.AppBarLayout$LayoutParams.<init>
02-26 19:59:37.026 848-848/com.example.lorlormensah.taxapp W/dalvikvm: VFY: unable to resolve direct method 18478: Landroid/widget/LinearLayout$LayoutParams;.<init> (Landroid/widget/LinearLayout$LayoutParams;)V
02-26 19:59:37.026 848-848/com.example.lorlormensah.taxapp D/dalvikvm: VFY: replacing opcode 0x70 at 0x0000
02-26 19:59:37.166 848-848/com.example.lorlormensah.taxapp I/dalvikvm: Could not find method android.content.res.Resources.getDrawable, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawable
02-26 19:59:37.176 848-848/com.example.lorlormensah.taxapp W/dalvikvm: VFY: unable to resolve virtual method 384: Landroid/content/res/Resources;.getDrawable (ILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
02-26 19:59:37.176 848-848/com.example.lorlormensah.taxapp D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
02-26 19:59:37.197 848-848/com.example.lorlormensah.taxapp I/dalvikvm: Could not find method android.content.res.Resources.getDrawableForDensity, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawableForDensity
02-26 19:59:37.197 848-848/com.example.lorlormensah.taxapp W/dalvikvm: VFY: unable to resolve virtual method 386: Landroid/content/res/Resources;.getDrawableForDensity (IILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
02-26 19:59:37.216 848-848/com.example.lorlormensah.taxapp D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
02-26 19:59:37.776 848-848/com.example.lorlormensah.taxapp D/dalvikvm: GC_FOR_ALLOC freed 150K, 10% free 2716K/2992K, paused 97ms, total 106ms
02-26 19:59:37.806 848-848/com.example.lorlormensah.taxapp I/dalvikvm-heap: Grow heap (frag case) to 3.377MB for 635812-byte allocation
02-26 19:59:37.907 848-857/com.example.lorlormensah.taxapp D/dalvikvm: GC_FOR_ALLOC freed 2K, 8% free 3334K/3616K, paused 98ms, total 99ms
02-26 19:59:38.646 848-848/com.example.lorlormensah.taxapp D/AndroidRuntime: Shutting down VM
02-26 19:59:38.646 848-848/com.example.lorlormensah.taxapp W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x41465730)
02-26 19:59:39.016 848-848/com.example.lorlormensah.taxapp E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.lorlormensah.taxapp/com.example.lorlormensah.taxapp.MainActivity}: java.lang.NumberFormatException: Invalid double: ""
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access0(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NumberFormatException: Invalid double: ""
at java.lang.StringToReal.invalidReal(StringToReal.java:63)
at java.lang.StringToReal.parseDouble(StringToReal.java:248)
at java.lang.Double.parseDouble(Double.java:295)
at com.example.lorlormensah.taxapp.MainActivity.onCreate(MainActivity.java:36)
at android.app.Activity.performCreate(Activity.java:5133)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access0(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
02-26 20:04:39.726 848-848/com.example.lorlormensah.taxapp I/Process: Sending signal. PID: 848 SIG: 9
realSalary 和 realAllowance 双精度值导致崩溃,请检查它们是否为空
尝试以下操作:
EditText payable;
Button calculate;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
EditText salary = (EditText) findViewById(R.id.edit_salary);
EditText allowance = (EditText) findViewById(R.id.edit_allowance);
EditText incomeTax = (EditText) findViewById(R.id.IncTax_edit);
EditText payable = (EditText) findViewById(R.id.payable_edit);
EditText totalTax = (EditText) findViewById(R.id.deduction_edit);
Button calculate = (Button) findViewById(R.id.calculate_button);
if(salary.getText().toString().length()>0)
{
double realSalary=Double.parseDouble(salary.getText().toString());
}
if(allowance.getText().toString().length()>0)
{
double realAllowance = Double.parseDouble(allowance.getText().toString());
}