我的应用程序在NPE上崩溃了,即使我正在检查String的值是否为非null:
if (AppConstants.AppConstants_appName != null &&
AppConstants.AppConstants_appName.equals("xxx")) {
suffix = "version=1.0";
}
AppConstants_appName是一个公共静态字符串。 不知道这里出了什么问题。 这是我的Stacktrace。有人有想法吗?
堆栈跟踪
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
at nl.onlineretailservice.library.APIManager.getURLSuffix(APIManager.java:637)
at nl.onlineretailservice.library.APIManager.requestFolderProducts(APIManager.java:334)
at nl.onlineretailservice.helper.FolderViewerActivityHelper.loadProducts(FolderViewerActivityHelper.java:160)
at nl.onlineretailservice.helper.FolderViewerActivityHelper$2.downloadReady(FolderViewerActivityHelper.java:267)
at nl.onlineretailservice.library.DownloadOperation.onPostExecute(DownloadOperation.java:221)
at android.os.AsyncTask.finish(AsyncTask.java:632)
at android.os.AsyncTask.access$600(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5832)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)