Android多个包问题

时间:2012-08-22 08:20:34

标签: android

我在我的eclipse中有项目,我使用了所有包的前缀相同的多个包。这是结构的截图!

Eclipse IDE screenshot

问题是,当我运行应用程序时,我收到此错误消息:

  

无法启动活动ComponentInfo {com.td.bookshelf / com.td.bookshelf.SplashActivity}:java.lang.NullPointerException)

我手动添加了所有包,并从其他项目中复制了类文件。 所以我清理了构建项目并重新启动了日食,但是徒劳无功。

请帮我摆脱错误。

08-22 13:43:07.367: E/AndroidRuntime(4900): FATAL EXCEPTION: main
08-22 13:43:07.367: E/AndroidRuntime(4900): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.td.bookshelf/com.td.bookshelf.SplashActivity}: java.lang.NullPointerException
08-22 13:43:07.367: E/AndroidRuntime(4900):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
08-22 13:43:07.367: E/AndroidRuntime(4900):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
08-22 13:43:07.367: E/AndroidRuntime(4900):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
08-22 13:43:07.367: E/AndroidRuntime(4900):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
08-22 13:43:07.367: E/AndroidRuntime(4900):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-22 13:43:07.367: E/AndroidRuntime(4900):     at android.os.Looper.loop(Looper.java:123)
08-22 13:43:07.367: E/AndroidRuntime(4900):     at android.app.ActivityThread.main(ActivityThread.java:3687)
08-22 13:43:07.367: E/AndroidRuntime(4900):     at java.lang.reflect.Method.invokeNative(Native Method)
08-22 13:43:07.367: E/AndroidRuntime(4900):     at java.lang.reflect.Method.invoke(Method.java:507)
08-22 13:43:07.367: E/AndroidRuntime(4900):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
08-22 13:43:07.367: E/AndroidRuntime(4900):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
08-22 13:43:07.367: E/AndroidRuntime(4900):     at dalvik.system.NativeStart.main(Native Method)
08-22 13:43:07.367: E/AndroidRuntime(4900): Caused by: java.lang.NullPointerException
08-22 13:43:07.367: E/AndroidRuntime(4900):     at com.td.bookshelf.SplashActivity.onCreate(SplashActivity.java:56)
08-22 13:43:07.367: E/AndroidRuntime(4900):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-22 13:43:07.367: E/AndroidRuntime(4900):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
08-22 13:43:07.367: E/AndroidRuntime(4900):     ... 11 more

1 个答案:

答案 0 :(得分:1)

看起来错误是来自您的包结构。

在堆栈跟踪中,您可以阅读:

E/AndroidRuntime(4900): Caused by: java.lang.NullPointerException
E/AndroidRuntime(4900):     at com.td.bookshelf.SplashActivity.onCreate(SplashActivity.java:56)

当调用SplashActivity的NullPointerException方法时,您获得onCreate

您的onCreate方法可能存在问题。