Search Unity

Has anybody tried integrating OpenFeint Android with Unity Android?

Discussion in 'Android' started by Tetrad, Oct 4, 2010.

  1. Tetrad

    Tetrad

    Joined:
    Jul 22, 2009
    Posts:
    45
    Just looking at the OpenFeint SDK and going through the documentation it isn't readily apparent if it's possible to put the two together. Has anybody had any experience in the matter?
     
  2. akasurreal

    akasurreal

    Joined:
    Jul 17, 2009
    Posts:
    439
    I would also like to know about this.
     
  3. floky

    floky

    Joined:
    Oct 6, 2010
    Posts:
    232
    Yes, I've also been searching for some way to integrate Openfeint for iPhone and Android in Unity, but I haven't been successful in finding something helpful yet.

    If someone finds out anything helpful about this, please post! :(
     
  4. defjr

    defjr

    Joined:
    Apr 27, 2009
    Posts:
    436
    Anyone?
     
  5. BuzzJive_Legacy

    BuzzJive_Legacy

    Joined:
    Oct 11, 2010
    Posts:
    26
    I can report that I'm making good progress, but it's very convoluted and I don't have the time to put together a proper demo scene to really help everybody else (and it sounds like Unity 3.1 should make this process much simpler). I can point you in the direction I took - but it's not for the feint (ha) of heart.

    I started with the AdMob example project to put together a proper UnityPlayerActivity class (and the associated AndroidManifest, which needed to be modified slightly for OpenFeint). In the UnityPlayerActivity subclass, I basically just initialize OpenFeint with the settings for our game. Upon building the apk, you must then decompose the apk using apktool, add the proper openfeint resources (specifically the res folder and the assets folder), then repackage the apk (remember to sign it again - the demo cert works until release of course). That will make sure OpenFeint is hanging around doing it's thing and has the resources it needs. (BTW, the unpack and repack sounds like something Unity 3.1 is going to help fix, based on comments I've seen from the admins).

    In order to actually use OpenFeint though, you'll need to put together another Android plugin, which I based off the java example plugin (the one with the JNI NativeBridge stuff). So far I've been able to create a Unity callable function to pull up the dashboard and one to submit a high score (no notification just yet).

    It's been 3 and a half days since I started working on this, and the first 2 were mostly throwaway after hitting various things that were either dead ends or looked like dead ends. But I think if you start in the right place, you can get to where I am in about a day.
     
  6. Wozik

    Wozik

    Joined:
    Apr 10, 2009
    Posts:
    662
    BuzzJive, Unity 3.1 will be much better in Android plugins support. I can add you to the beta where the preview version of 3.1 is available. Just email me to oleg@unity3d.com if you'd like to posess the new Unity 3.1 beta.
     
  7. eriQue

    eriQue

    Unity Technologies

    Joined:
    May 25, 2010
    Posts:
    592
    Because this topic has come up a few times (both here on the forums, and on the beta list) I've created a sample facade object for OpenFeint. It's not a fire-and-forget solution: you will need to alter the contents of this package to fit your needs (at the very least provide accurate login information).
    If you change the C# scripts you only need to Build&Run from the editor (as usual).
    If you change the Java code you need to rebuild the OpenFeintFacade.jar - the scripts provided uses ANT for this.
    If you change the native code (jni.cpp) you need to rebuild the native library (libjni.so) - the build scripts for that uses the standard NDK make.
     

    Attached Files:

  8. christo

    christo

    Joined:
    Nov 23, 2010
    Posts:
    15
    Thanks so much for your work on this. Like I noted in the beta group, I got this working in 30 minutes, and most of that time was spent setting things up at openfeint.

    For anyone implementing this: Just open the .unitypackage while in your project that you wish to use openfeint with. It will open a dialog with a bunch of files, import them all.
    Then just follow the few steps in the readme.txt that you just imported (if you have not downloaded openfeint/android sdks, you will need to do so).
    Now if you include the openfeinttest scene in your build settings and build and run on an android device, you will get a screen with a few buttons that allow you to login to openfeint, post a static score, etc.
    I tested logging out of openfeint and running this, it will prompt you to log in!
    All of these commands are in the openfeinttest.cs script and are quite readable, you can simply implement these calls however you wish in your game (for example, initializing openfeint once the game starts, rather than on a button press).

    +10 internets to erique. I know a lot of people were looking for this and simply didn't have the knowledge to accomplish it.
     
  9. mmuller

    mmuller

    Joined:
    Nov 23, 2010
    Posts:
    87
    erique,

    I don't suppose you could put together a more comprehensive tutorial for how to integrate the openfeint system and the leaderboards into an Android game. ie. what api's are available etc etc and how to access elements returned from openfeint?

    Many thanks for the package by the way - its certainly a step in the right direction :D
     
  10. dimitris

    dimitris

    Joined:
    Oct 20, 2010
    Posts:
    5
    @mmuller, you can see the APIs by looking at the facade source code, it only contains a method to init OF, to submit a score and to submit an achievement at the moment. The problem is I can't get it to work on an Android phone...

    @erique, is there a support page/forum-post for this unity package? I am following the simple instructions in the readme but my app crashes on launch.
     
  11. Joel-Santos

    Joel-Santos

    Joined:
    Feb 23, 2010
    Posts:
    118
    Any help on why am I getting this message: DllNotFoundException: jni?

    And also this part? I think they are linked:

     
    Last edited: Jan 23, 2011
  12. Joel-Santos

    Joel-Santos

    Joined:
    Feb 23, 2010
    Posts:
    118
    No help on this? Was really interested on using open feint in my game, since you can upload data and I can no longer use stack.dimeRocker
     
  13. pepworks

    pepworks

    Joined:
    Jan 18, 2010
    Posts:
    19
    Opening the facade.unitypackage gives me

    DllNotFoundException: jni
    OpenFeintFacade.isUserLoggedIn () (at Assets/Plugins/OpenFeintFacade.cs:46)
    OpenFeintTest.OnGUI () (at Assets/OpenFeintTest.cs:17)

    What is wrong here? Do I have to add the jni (Dll) somewhere?

    thanks,

    pep
     
  14. Curious

    Curious

    Joined:
    Nov 19, 2009
    Posts:
    334
    Hey guys, I'm trying to get this to work, I have the latest OF Android SDK and have copied the necessary file into their respective folders, and I've compiled the project successfully but when I run the application form my device (hTC Desire z) it doesn't come up! It quits right after the load screen with no error(s).

    Any help would be highly appreciated.
    Thanks
     
  15. dimitris

    dimitris

    Joined:
    Oct 20, 2010
    Posts:
    5
    That's exactly what happened to me as well.
     
  16. Curious

    Curious

    Joined:
    Nov 19, 2009
    Posts:
    334
    That's lame! There's got to be a way around this, I'm quiet sure! May be 3.2 will handle this, right? Anyone from UT? Can you confirm this please?

    My app is in iTunes right now and I can't wait to see it on the Android market as well :)

    Help us please!
    Thank you
     
  17. Curious

    Curious

    Joined:
    Nov 19, 2009
    Posts:
    334
    OK, I'm trying to find a solution with your help guys, so here I go!
    First off, here is a quite from the Readme file of the unity package provided here:
    I've copied the assets and res to my Unity project but there's no folder named 'libs'! (I'm using OF 1.7 SDK - Android)
    And there's a 'src' folder instead, I believe they are java codes, so my guess, we should probably compile them, right? But how?

    Anyone?
    Any help would be appreciated guys,
    Thanks
     
  18. BuzzJive_Legacy

    BuzzJive_Legacy

    Joined:
    Oct 11, 2010
    Posts:
    26
    In my experience, OF 1.7 and Unity 3.1 are not compatible. They both try to make use of default XML layouts and conflict with each other. The only OF I can get to run properly is 1.0.1 - which is a pretty early version that they don't even let you download anymore. I was able to get some sort of minor debug info out of OF 1.7 through the ddms tool, but it definitely wasn't helpful. I eventually tracked down some crash when accessing the xml files and tried to put some logging statements in the OF source itself. I spent about a day and a half on it before just settling back to 1.0.1.

    I should have documented my process, but I didn't. The gist of it is that yes, you need to build the OpenFeint src into an OpenFeint.jar that you can drop in to your plugins folder (I had eclipse issues and eventually got it to compile through ant - and then I made it a jar). You need a subclass of UnityPlayerActivity that initializes OpenFeint with your settings. You need a modified AndroidManifest.xml in your Plugins/Android folder that loads your UnityPlayerActivity class and has all the other necessary OpenFeint activity settings.

    It's not a straightforward process at all.
     
  19. Curious

    Curious

    Joined:
    Nov 19, 2009
    Posts:
    334
    Wow, I think we need help from both UT an OF guys! But I won't stop digging ;)

    Thanks for the info
     
  20. spire8989

    spire8989

    Joined:
    Aug 18, 2010
    Posts:
    94
    Ten hours straight today with 3.2 and I have gotten the most recent version of OpenFeint Android working with Unity! I'm very excited.

    I'm too tired now to do a write-up or anything, but I will say that I used the .unityPackage above and customized a lot of things, produced my own .jar, etc.

    If anyone is having a specific problem such as the app immediately closing (it was doing that to me before), just post it here and I'll try to help you in the morning.
     
  21. Wozik

    Wozik

    Joined:
    Apr 10, 2009
    Posts:
    662
  22. Curious

    Curious

    Joined:
    Nov 19, 2009
    Posts:
    334
    @spire8989,
    Yeah, I've still got the same old problem with right-after-splash-screen-crash!

    I'm using C# though!

    Thanks in advance
     
  23. spire8989

    spire8989

    Joined:
    Aug 18, 2010
    Posts:
    94
  24. Curious

    Curious

    Joined:
    Nov 19, 2009
    Posts:
    334
    Got it to work, I just had to upgrade to revision 9

    Thank you VERY much :D
     
  25. Wozik

    Wozik

    Joined:
    Apr 10, 2009
    Posts:
    662
    spire8989, well, then check out who made it better and may be contribute to the plugin we made available for everyone to benefit.
     
  26. kickerks8080

    kickerks8080

    Joined:
    Feb 23, 2010
    Posts:
    10
    For anyone who needs a AndroidManifest.xml file that supports Prime31 flurry plugin and Openfeint use this.

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.unity3d.player"
    android:installLocation="preferExternal"
    android:versionCode="1"
    android:versionName="1.0" >
    <uses-sdk android:minSdkVersion="7" />
    <supports-screens
    android:anyDensity="true"
    android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:xlargeScreens="true" />

    <!-- PERMISSIONS -->
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_ST ATE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE " />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_ST ORAGE" />

    <application
    android:debuggable="true"
    android:icon="@drawable/app_icon"
    android:label="@string/app_name" >
    <activity android:name="com.gree.giraffe.BaseActivity" android:configChanges="fontScale|keyboard|keyboard Hidden|locale|mnc|mcc|navigation|orientation|scree nLayout|screenSize|smallestScreenSize|uiMode|touch screen" android:label="@string/app_name" >
    <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    </activity>
    <!-- WILL NEED TO REFACTOR TO MAKE com.gree.giraffe.BaseActivity the MAIN ACTIVITY (It extends from UnityPlayerActivity)
    <activity
    android:name="com.unity3d.player.UnityPlayerProxyA ctivity"
    android:configChanges="fontScale|keyboard|keyboard Hidden|locale|mnc|mcc|navigation|orientation|scree nLayout|screenSize|smallestScreenSize|uiMode|touch screen"
    android:label="@string/app_name" >
    <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    </activity>
    -->
    <activity
    android:name="com.unity3d.player.UnityPlayerActivi ty"
    android:configChanges="fontScale|keyboard|keyboard Hidden|locale|mnc|mcc|navigation|orientation|scree nLayout|screenSize|smallestScreenSize|uiMode|touch screen"
    android:label="@string/app_name" >
    </activity>
    <activity
    android:name="com.unity3d.player.UnityPlayerNative Activity"
    android:configChanges="fontScale|keyboard|keyboard Hidden|locale|mnc|mcc|navigation|orientation|scree nLayout|screenSize|smallestScreenSize|uiMode|touch screen"
    android:label="@string/app_name" >
    <meta-data
    android:name="android.app.lib_name"
    android:value="unity" />
    <meta-data
    android:name="unityplayer.ForwardNativeEventsToDal vik"
    android:value="false" />
    </activity>
    <activity
    android:name="com.unity3d.player.VideoPlayer"
    android:configChanges="fontScale|keyboard|keyboard Hidden|locale|mnc|mcc|navigation|orientation|scree nLayout|screenSize|smallestScreenSize|uiMode|touch screen"
    android:label="@string/app_name" >
    </activity>

    <!-- ACTIVITIES -->
    <activity
    android:name="com.flurry.android.CatalogActivity"
    android:theme="@android:style/Theme.Translucent" >
    <intent-filter>
    <action android:name="make.me.unique.please" />

    <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
    </activity>
    <!-- OpenFeint Activities -->
    <activity android:name="com.openfeint.internal.ui.IntroFlow"
    android:label="IntroFlow"
    android:configChanges="orientation|keyboardHidden"
    android:theme="@style/OFNestedWindow" />
    <activity android:name="com.openfeint.api.ui.Dashboard"
    android:label="Dashboard"
    android:configChanges="orientation|keyboardHidden"
    android:theme="@style/OFNestedWindow"/>
    <activity android:name="com.openfeint.internal.ui.Settings"
    android:label="Settings"
    android:configChanges="orientation|keyboardHidden"
    android:theme="@style/OFNestedWindow"/>
    <activity android:name="com.openfeint.internal.ui.NativeBrow ser"
    android:label="NativeBrowser"
    android:configChanges="orientation|keyboardHidden"
    android:theme="@style/OFNestedWindow"/>

    <!-- ofx activity -->
    <activity
    android:configChanges="orientation|keyboardHidden"
    android:label="Please confirm your account"
    android:name="com.openfeint.ofx.activity.AttachAcc ountActivity"
    android:theme="@style/OFNestedWindow" />
    <activity
    android:configChanges="orientation|keyboardHidden"
    android:label="Please secure your account"
    android:name="com.openfeint.ofx.activity.SecureAcc ountActivity"
    android:theme="@style/OFNestedWindow" />
    <activity
    android:configChanges="orientation|keyboardHidden"
    android:name="com.openfeint.ofx.activity.ChooseAcc ountFlowActivity"
    android:theme="@style/OFNestedWindow" />

    <!-- use ofx service and receiver -->
    <service android:name="com.openfeint.ofx.service.BillingSer vice" />

    <receiver android:name="com.openfeint.ofx.broadcastreceiver. BillingReceiver" >
    <intent-filter >
    <action android:name="com.android.vending.billing.IN_APP_N OTIFY" />
    <action android:name="com.android.vending.billing.RESPONSE _CODE" />
    <action android:name="com.android.vending.billing.PURCHASE _STATE_CHANGED" />
    </intent-filter>
    </receiver>

    <!-- META-DATA -->

    </application>

    </manifest>