Roboguice示例astroboy无法使用NullPointerException

时间:2014-11-25 08:55:57

标签: android roboguice

我是RoboGuice的新手, 在克隆git存储库之后,我做了以下事情:

mvn install

显示成功。 然后我cd到astroboy并执行:

mvn package

mvn android:deploy

它告诉我找不到android-support相关的类,然后我添加了依赖项,但仍然得到:

11-25 16:41:50.984 7957-7957/org.roboguice.astroboy I/Process﹕ Sending signal. PID: 7957 SIG: 9
11-25 16:41:51.844 8095-8095/org.roboguice.astroboy D/roboguice.RoboGuice﹕ Using annotation database(s).
11-25 16:41:51.854 8095-8095/org.roboguice.astroboy D/roboguice.RoboGuice﹕ Using annotation database(s) : [, roboguice]
11-25 16:41:51.854 8095-8095/org.roboguice.astroboy D/roboguice.RoboGuice﹕ Time spent loading annotation databases : 4
11-25 16:41:51.984 8095-8095/org.roboguice.astroboy E/MoreInfoHPW_ViewGroup﹕ Parent view is not a TextView
11-25 16:41:52.054 8095-8095/org.roboguice.astroboy D/AndroidRuntime﹕ Shutting down VM
11-25 16:41:52.054 8095-8095/org.roboguice.astroboy W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41c5f898)
11-25 16:41:52.054 8095-8095/org.roboguice.astroboy E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NullPointerException
at org.roboguice.astroboy.view.CustomView.onAttachedToWindow(CustomView.java:38)
at android.view.View.dispatchAttachedToWindow(View.java:13030)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2683)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2690)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2690)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2690)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2690)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1461)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1253)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6402)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:791)
at android.view.Choreographer.doCallbacks(Choreographer.java:591)
at android.view.Choreographer.doFrame(Choreographer.java:561)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:777)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:5493)
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:1225)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1041)
at dalvik.system.NativeStart.main(Native Method)

有任何评论吗?

1 个答案:

答案 0 :(得分:4)

如果您指的是Astroboy Example,以下是可能的解决方案之一。

您可以添加以下行:

for a in `seq 6 -1 0`;
do
    dt=`date "+%F" --date=" -"$a" days"`;
    f=$dt".log";
    cat $f >> "1_week.log";
done;
<布局通胀后

RoboGuice.injectMembers(getContext(), this);
RoboGuice.getInjector(getContext()).injectViewMembers(this);
initializeView()方法中的

。然后问题就可以解决了。