Attempt to invoke interface method 'java.util.Iterator java.util.List.iterator()' on a null object

Process: com.xxx.yyy
Flags: 0xc8be45
Package: com.xxx.yyy v1000 (xxxxxxx-yyyyyyyy)
Build: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz:eng/test-keys

java.lang.NullPointerException: Attempt to invoke interface method 'java.util.Iterator java.util.List.iterator()' on a null object reference
    at android.os.Parcel.readException(Parcel.java:1552)
    at android.os.Parcel.readException(Parcel.java:1499)
    at com.android.internal.view.IInputMethodManager$Stub$Proxy.showInputMethodPickerFromClient(IInputMethodManager.java:753)
    at android.view.inputmethod.InputMethodManager.showInputMethodPickerLocked(InputMethodManager.java:1898)
    at android.view.inputmethod.InputMethodManager.dispatchInputEvent(InputMethodManager.java:1755)
    at android.view.ViewRootImpl$ImeInputStage.onProcess(ViewRootImpl.java:3853)
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544)
    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3597)
    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3563)
    at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3571)
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544)
    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3597)
    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3563)
    at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3680)
    at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3571)
    at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3737)
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544)
    at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5807)
    at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5781)
    at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5752)
    at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:5897)
    at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
    at android.os.MessageQueue.nativePollOnce(Native Method)
    at android.os.MessageQueue.next(MessageQueue.java:143)
    at android.os.Looper.loop(Looper.java:122)
    at android.app.ActivityThread.main(ActivityThread.java:5267)
    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:903)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

一看到java.lang.NullPointerException是不是很高兴?

再看到Attempt to invoke interface method 'java.util.Iterator java.util.List.iterator()' on a null object reference

是不是觉得很容易解决?

但是没有一行com.xxx.yyy代码时是不是没有头续了?

我们先来看一下堆栈最后一行:

at android.os.Parcel.readException(Parcel.java:1552)

1543      public final void readException(int code, String msg) {
1544          switch (code) {
1545              case EX_SECURITY:
1546                  throw new SecurityException(msg);
1547              case EX_BAD_PARCELABLE:
1548                  throw new BadParcelableException(msg);
1549              case EX_ILLEGAL_ARGUMENT:
1550                  throw new IllegalArgumentException(msg);
1551              case EX_NULL_POINTER:
1552                  throw new NullPointerException(msg);
1553              case EX_ILLEGAL_STATE:
1554                  throw new IllegalStateException(msg);
1555              case EX_NETWORK_MAIN_THREAD:
1556                  throw new NetworkOnMainThreadException();
1557              case EX_UNSUPPORTED_OPERATION:
1558                  throw new UnsupportedOperationException(msg);
1559          }
1560          throw new RuntimeException("Unknown exception code: " + code
1561                  + " msg " + msg);
1562      }

空指针异常就是1552行抛出来的,IInputMethodManager.java源码是没有的,因为它是IInputMethodManager.aldl自动生成的,此时没有APP com.xxx.yyy的任何代码堆栈,但是结合以往看到的IXXX.java代码,应该是Proxy中transact调用结束后的那一句readException抛出来的,说明问题出在InputMethodManagerService。

再次重现bug,观察系统所有日志输出,我们发现:

android.util.Log$TerribleFailure: Input Method Manager Crash
	at android.util.Log.wtf(Log.java:291)
	at android.util.Slog.wtf(Slog.java:116)
	at com.android.server.InputMethodManagerService.onTransact(InputMethodManagerService.java:879)
	at android.os.Binder.execTransact(Binder.java:446)
Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'java.util.Iterator java.util.List.iterator()' on a null object reference
	at com.android.server.InputMethodManagerService.isServiceRunning(InputMethodManagerService.java:993)
	at com.android.server.InputMethodManagerService.showInputMethodPickerFromClient(InputMethodManagerService.java:2154)
	at com.android.internal.view.IInputMethodManager$Stub.onTransact(IInputMethodManager.java:237)
	at com.android.server.InputMethodManagerService.onTransact(InputMethodManagerService.java:874)
	... 1 more

所以修正InputMethodManagerService.java的迭代器空指针异常即可解决问题。

 

 

 

你可能感兴趣的:(android)