初始化时的群集错误

时间:2013-03-05 12:55:11

标签: java android nullpointerexception

我正在尝试在我的游戏中集成swarm排行榜但我得到了NullPointerException。在我的onCreate主要活动方法中放置了init行:

Swarm.init(this, 4583, "e8398d93819da3d6d5f7dxxxxxxxxx");

我编辑了一点我的代码ID。 :)

现在我在logcat中收到此错误:

    03-05 14:16:02.543: I/Swarm(26723): Swarm Version v1
03-05 14:16:02.633: I/SwarmIOClient(26723): SwarmIO ClientID: f078ccf2-837e-4d6d-b53f-8b2f63a26d84
03-05 14:16:03.653: D/dalvikvm(26723): GC_CONCURRENT freed 262K, 50% free 2852K/5639K, external 0K/0K, paused 11ms+13ms
03-05 14:16:04.273: W/ResourceType(26723): No package identifier when getting value for resource number 0x00000000
03-05 14:16:04.273: D/AndroidRuntime(26723): Shutting down VM
03-05 14:16:04.273: W/dalvikvm(26723): threadid=1: thread exiting with uncaught exception (group=0x40018560)
03-05 14:16:04.333: E/AndroidRuntime(26723): FATAL EXCEPTION: main
03-05 14:16:04.333: E/AndroidRuntime(26723): java.lang.RuntimeException: Unable to start activity ComponentInfo{rs.androidaplikacijekvizopstekulture/com.swarmconnect.SwarmMainActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x0
03-05 14:16:04.333: E/AndroidRuntime(26723):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1768)
03-05 14:16:04.333: E/AndroidRuntime(26723):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
03-05 14:16:04.333: E/AndroidRuntime(26723):    at android.app.ActivityThread.access$1500(ActivityThread.java:123)
03-05 14:16:04.333: E/AndroidRuntime(26723):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
03-05 14:16:04.333: E/AndroidRuntime(26723):    at android.os.Handler.dispatchMessage(Handler.java:99)
03-05 14:16:04.333: E/AndroidRuntime(26723):    at android.os.Looper.loop(Looper.java:130)
03-05 14:16:04.333: E/AndroidRuntime(26723):    at android.app.ActivityThread.main(ActivityThread.java:3835)
03-05 14:16:04.333: E/AndroidRuntime(26723):    at java.lang.reflect.Method.invokeNative(Native Method)
03-05 14:16:04.333: E/AndroidRuntime(26723):    at java.lang.reflect.Method.invoke(Method.java:507)
03-05 14:16:04.333: E/AndroidRuntime(26723):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
03-05 14:16:04.333: E/AndroidRuntime(26723):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
03-05 14:16:04.333: E/AndroidRuntime(26723):    at dalvik.system.NativeStart.main(Native Method)
03-05 14:16:04.333: E/AndroidRuntime(26723): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
03-05 14:16:04.333: E/AndroidRuntime(26723):    at android.content.res.Resources.getValue(Resources.java:929)
03-05 14:16:04.333: E/AndroidRuntime(26723):    at android.content.res.Resources.loadXmlResourceParser(Resources.java:1955)
03-05 14:16:04.333: E/AndroidRuntime(26723):    at android.content.res.Resources.getLayout(Resources.java:768)
03-05 14:16:04.333: E/AndroidRuntime(26723):    at android.view.LayoutInflater.inflate(LayoutInflater.java:318)
03-05 14:16:04.333: E/AndroidRuntime(26723):    at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
03-05 14:16:04.333: E/AndroidRuntime(26723):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:213)
03-05 14:16:04.333: E/AndroidRuntime(26723):    at android.app.Activity.setContentView(Activity.java:1657)
03-05 14:16:04.333: E/AndroidRuntime(26723):    at com.swarmconnect.ao.b(Unknown Source)
03-05 14:16:04.333: E/AndroidRuntime(26723):    at com.swarmconnect.ax.onCreate(Unknown Source)
03-05 14:16:04.333: E/AndroidRuntime(26723):    at com.swarmconnect.SwarmMainActivity.onCreate(Unknown Source)
03-05 14:16:04.333: E/AndroidRuntime(26723):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-05 14:16:04.333: E/AndroidRuntime(26723):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
03-05 14:16:04.333: E/AndroidRuntime(26723):    ... 11 more
03-05 14:16:04.533: D/dalvikvm(26723): GC_CONCURRENT freed 448K, 50% free 2973K/5895K, external 0K/0K, paused 6ms+13ms
03-05 14:16:06.773: D/dalvikvm(26723): GC_CONCURRENT freed 384K, 49% free 3039K/5959K, external 0K/0K, paused 6ms+15ms

我的清单文件:

<activity android:name="com.swarmconnect.SwarmMainActivity"
    android:screenOrientation="landscape"
    android:configChanges="orientation|keyboardHidden"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
    android:windowSoftInputMode="stateHidden">
            </activity>

我确实导入了他们说我需要的一切。有什么问题?

3 个答案:

答案 0 :(得分:0)

查看你的logcat:

  

引起:android.content.ActivityNotFoundException:无法找到   显性活动类   {rs.androidaplikacijekvizopstekulture / com.swarmconnect.SwarmMainActivity};   你有没有在AndroidManifest.xml中声明这个活动?

答案 1 :(得分:0)

好的,我发现了问题所在。我需要复制我的文件夹中的所有布局,资源,drawable和东西。我不知道。他们在他们的教程中没有提到这一点。所以,当我这样做时,游戏开始很好。谢谢你的麻烦。

答案 2 :(得分:0)

@ user2083882

听起来你正在使用旧版本的Swarm Android SDK。最新版本的Swarm SDK是一个库项目,因此不需要将SDK zip文件中的文件复制到项目中。图书馆项目使您的社交功能(排行榜,成就等)更容易实现,您将永远不必再次记住此文件复制步骤:)。干杯!