当我找到答案时,我会把自己踢得遍体鳞伤,但我很困惑,所以:
我得到了一个
NullPointerException
(一些)用户在尝试访问OneDrive时报告。当然,我自己无法复制。我正在使用Microsoft的OneDrive SDK。
FileListItem
是我正在尝试填充的类
success()
SDK回调的方法。错误的位置来自Google Play开发者控制台错误详细信息中的堆栈跟踪。
final ICallback<IItemCollectionPage> callback = new ICallback<IItemCollectionPage>() {
@Override
public void success(final IItemCollectionPage result) {
for (Item child : result.getCurrentPage()) {
FileListItem item = new FileListItem();
item.name = child.name;
if (child.parentReference != null) {
item.sourcePath = child.parentReference.path; // java.lang.NullPointerException
}
...
所以
child
来自
for
循环遍历传递给的(可能有效)列表
成功
,它不会崩溃
child.name
和
child.parentReference != null
.
我的问题是如果
item
是我刚刚创建的有效对象,并且
child.parentReference!=无效的
,这些用户怎么会得到
空指针异常
?
已编辑以添加完整堆栈跟踪:
java.lang.NullPointerException:
at [myapp].OneDriveProvider$4.success (OneDriveProvider.java:183)
at [myapp].OneDriveProvider$4.success (OneDriveProvider.java:176)
at com.onedrive.sdk.concurrency.DefaultExecutors$1.run (DefaultExecutors.java:88)
at com.onedrive.sdk.concurrency.SynchronousExecutor$1.onPostExecute (SynchronousExecutor.java:54)
at com.onedrive.sdk.concurrency.SynchronousExecutor$1.onPostExecute (SynchronousExecutor.java:46)
at android.os.AsyncTask.finish (AsyncTask.java:755)
at android.os.AsyncTask.access$900 (AsyncTask.java:192)
at android.os.AsyncTask$InternalHandler.handleMessage (AsyncTask.java:772)
at android.os.Handler.dispatchMessage (Handler.java:107)
at android.os.Looper.loop (Looper.java:214)
at android.app.ActivityThread.main (ActivityThread.java:7397)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:935)