Java 安卓:是什么让我的应用程序崩溃?

Java 安卓:是什么让我的应用程序崩溃?,java,android,crash,report,nullpointerexception,Java,Android,Crash,Report,Nullpointerexception,我每天都会收到一些错误,我不知道发生了什么 如果需要更多信息,请告诉我 我可能没有提供足够的信息 以下是我在开发人员控制台中遇到的错误: java.lang.RuntimeException: Unable to destroy activity {com.Calculator.SalesTaxCalculator/com.Calculator.SalesTaxCalculator.Calculator}: java.lang.NullPointerException at android.ap

我每天都会收到一些错误,我不知道发生了什么

如果需要更多信息,请告诉我

我可能没有提供足够的信息

以下是我在开发人员控制台中遇到的错误:

java.lang.RuntimeException: Unable to destroy activity {com.Calculator.SalesTaxCalculator/com.Calculator.SalesTaxCalculator.Calculator}: java.lang.NullPointerException
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3199)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3264)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3380)
at android.app.ActivityThread.access$1600(ActivityThread.java:145)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1049)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:4369)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:846)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:604)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at android.content.ComponentName.<init>(ComponentName.java:75)
at android.content.Intent.<init>(Intent.java:2920)
at com.Calculator.SalesTaxCalculator.BillingHelper.stopService(BillingHelper.java:265)
at com.Calculator.SalesTaxCalculator.Calculator.onDestroy(Calculator.java:302)
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3181)
... 12 more
第301行及以后的代码(这是该页的最后一组代码)。

停止BillingHelper中的服务方法

public static void stopService(){
                mContext.stopService(new Intent(mContext, BillingService.class));
                mService = null;
                mContext = null;
                mCompletedHandler = null;
                Log.i(TAG, "Stopping Service");
        }
}

有人在崩溃报告中留言说,应用程序甚至没有打开。更多信息是,它使用共享首选项将数字保存在计算器中。还有一个捐赠按钮,使用应用内计费服务

将其更改为调用super.ondestory();首先是其他东西,例如:

@Override
protected void onDestroy() {
    super.onDestroy();
    BillingHelper.stopService();
}

Calculator.java:302也发布这一行。你应该粘贴的内容至少是你所有活动的详细代码。和计算器代码。因为它看起来有和错误。
BillingHelper.stopService()
可能也包含错误。请提供SalesTaxCalculator.java和Calculator.java文件的示例代码。添加了更多信息,请查看。您知道有什么方法可以测试这是否可以解决问题吗?我不知道这次崩溃是怎么回事,也不知道如何重做,15000多人中只有16人有这个问题。我测试过我的应用程序的每一台设备都与该应用程序一起工作。这个问题是在我向我的应用程序添加账单时开始的。BillingHelper的StopService方法中有什么内容?它与您启动服务时使用的上下文相同吗?您是否使用应用程序级上下文或活动级上下文来启动服务?无论哪种情况,您都应该使用相同的上下文来启动/停止服务。如果应用程序的上下文与启动服务时使用的上下文相同,请不要将上下文设置为null?您是否使用应用程序级上下文或活动级上下文来启动服务?无论哪种情况,您都应该使用相同的上下文来启动/停止服务。如果应用程序的上下文为空,请不要将上下文设置为空
public static void stopService(){
                mContext.stopService(new Intent(mContext, BillingService.class));
                mService = null;
                mContext = null;
                mCompletedHandler = null;
                Log.i(TAG, "Stopping Service");
        }
}
@Override
protected void onDestroy() {
    super.onDestroy();
    BillingHelper.stopService();
}