简体   繁体   中英

Swarm error at initialisation

I'm trying to integrate swarm leaderboard in my game but i get NullPointerException. Placed init line in my onCreate method of main activity:

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

I edited a little bit my code id. :)

Now i get this error in my 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

My Manifest file:

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

I did import everything they say I need to. What's the problem?

Look in your logcat:

Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {rs.androidaplikacijekvizopstekulture/com.swarmconnect.SwarmMainActivity}; have you declared this activity in your AndroidManifest.xml?

OK, i found where the problem is. I need to copy ALL the layout, resources, drawables and stuff in my folders. I did not know that. They did not mention that in their tutorial. So, when i did that, the game started fine. Thanks for your trouble.

@user2083882

It sounds like you're using an older version of the Swarm Android SDK. The latest version of Swarm SDK is a library project and thus doesn't require copying files from the SDK zip file into your project. The library project makes implementing your social features (leaderboards, achievements, etc.) a bunch easier and you'll never have to remember this file copying step again :). Cheers!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM