0

我正在尝试将 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>

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

4

3 回答 3

0

@user2083882

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

于 2013-03-07T15:20:36.220 回答
0

好的,我找到了问题所在。我需要复制文件夹中的所有布局、资源、可绘制对象和内容。我不知道。他们在教程中没有提到这一点。所以,当我这样做时,游戏开始正常。谢谢你的麻烦。

于 2013-03-05T13:31:12.670 回答
0

查看您的日志猫:

引起:android.content.ActivityNotFoundException:找不到明确的活动类{rs.androidaplikacijekvizopstekulture/com.swarmconnect.SwarmMainActivity};您是否在 AndroidManifest.xml 中声明了此活动?

于 2013-03-05T12:57:43.683 回答