Announcement

Collapse
No announcement yet.

Android Java Libraries in UE4 Game (OUYA SDK, Google Play Game Services, etc.)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Android Java Libraries in UE4 Game (OUYA SDK, Google Play Game Services, etc.)

    Is it possible to use Java Libraries in UE4 Game such as OUYA SDK or Google Play Services and Google Play Services?


    P.S.: Is there support for a Eclipse project for your Android UE4 game?

    #2
    It is possible, though the workflow isn't great (not sure we can make it any better either, due to how JNI works).

    Check out how Android's LaunchURL implementation works in AndroidJNI.cpp and GameActivity.java for an example of how C++ thunks across to Java.

    We will have limited (leaderboards and achievements) Google Play support coming in the 4.2 release (and you should be able to see the work-in-progress in the unstable branch on GitHub once the live mirroring turns on).

    We don't currently have any Eclipse support, not sure if there are any plans for it either. UBT could certainly be extended to generate Eclipse project files in addition to or instead of Visual Studio / Xcode projects.

    Cheers,
    Michael Noland

    Comment


      #3
      Would it be possible for you to explain to me how I would go about adding a .jar to a UE4 game. Or point me to a resource.

      Comment


        #4
        So, this is more involved than you probably want, but an early (really, don't use it quite yet ) version of our Google Play services integration can be found at:

        https://github.com/EpicGames/UnrealE...c4b473cfa5239f

        Some of the key changes related to adding a .jar are in UEDeployAndroid.cs, where we copy the Google Play services library to our Intermediates, and then run 'android.bat update' on it.

        Other important files are AndroidJNI.h/.cpp for calls across the C++/Java boundary, and AndroidManifest.xml, where we let the Android SDK build system know that we're integrating the Google Play services library.

        There may be a simpler approach for what you're looking to do, and if you find something that works better, please let us know.

        Comment


          #5
          Creating an Android Plugin and calling jar files from c++

          I had a look at the source files you suggested,
          but I still have multiple questions

          If I want to create a simple Android plugin:

          where do I need to place the .jar files In my Android game project?

          do I need to create UEDeployAndroid.cs, AndroidJNI.h/cpp equivalents for my plugin?

          how are you loading the jar files in UEDeployAndroid?

          I just need to load the android plugin in my c++ code and call a function from the jar file.

          If it is possible can you please explain what are the steps to follow for making this kind of Plugin
          so I have a clear understanding of how this is done in UE4

          thanks

          Comment


            #6
            Originally posted by JJ Hoesing View Post
            So, this is more involved than you probably want, but an early (really, don't use it quite yet ) version of our Google Play services integration can be found at:

            https://github.com/EpicGames/UnrealE...c4b473cfa5239f

            Some of the key changes related to adding a .jar are in UEDeployAndroid.cs, where we copy the Google Play services library to our Intermediates, and then run 'android.bat update' on it.

            Other important files are AndroidJNI.h/.cpp for calls across the C++/Java boundary, and AndroidManifest.xml, where we let the Android SDK build system know that we're integrating the Google Play services library.

            There may be a simpler approach for what you're looking to do, and if you find something that works better, please let us know.
            Thanks, looking at those commits was very helpful and finally managed to communicate Java <-> C++.
            But then I'm facing the problem that the manifest and Android project folder are being rewritten every time the project is built, as explained here: https://forums.unrealengine.com/show...oject-is-built

            Comment


              #7
              I just put all jar, libraries under C:\Program Files\Unreal Engine\4.1\Engine\Build\Android\Java

              Full directory structure:
              Engine\Build\Android\Java\jni\libmylib.so
              Engine\Build\Android\Java\libs\mylib.jar
              Engine\Build\Android\Java\libs\mylib.jar.properties (if you have)

              [EDIT]
              Also modified jni\Android.mk
              -------------------
              LOCAL_PATH := $(call my-dir)

              include $(CLEAR_VARS)
              LOCAL_MODULE := UE4
              LOCAL_SRC_FILES := libUE4.so
              include $(PREBUILT_SHARED_LIBRARY)

              include $(CLEAR_VARS)
              LOCAL_MODULE := mylib
              LOCAL_SRC_FILES := libmylib.so
              include $(PREBUILT_SHARED_LIBRARY)
              -------------------
              [/EDIT]

              So they are always copied to Intermediate directory during build time.
              I also edited GameActivity.java there to load my library.

              I'm afraid this is not a recommended way because I edited default installation.
              Please let me know better and recommended way.
              Last edited by Keewon Seo; 05-15-2014, 02:13 AM.

              Comment


                #8
                I do not believe there is a "better" way to do this.

                Comment


                  #9
                  Nobody has updated this for a while.

                  I managed to communicate between Blueprints (C++) and a external java library file. However, I only achieve this modifying AndroidJNI.cpp/h files. These files are part of the Engine and we don't want to modify the Engine, just the Game project files.

                  There was another change related to the game's java files (GameActivity.java). But that was easy. You just have your modified GameActivity.java in a replicated Build folder in your project's folder. For example the Android.mk file to add more .so files, as Keewon Seo suggests. And that;s what I am looking at now. If I am able to create a .so file (library) from a similar implementation of the AndroidJNI.cpp/h files I will have this working without modifying the Engine code.

                  Has anybody achieved Java-C++ communication without modifying the engine code?

                  Comment


                    #10
                    That https://github.com/aajiwani/EasyNDK-for-cocos2dx is good example for communication platform specific native code and C++.

                    Comment


                      #11
                      As far as the OUYA SDK, yes UE4 is now supported on OUYA. Check out the latest plugin and docs.
                      https://github.com/ouya/docs/blob/master/unreal.md

                      Comment


                        #12
                        As for the eclipse support, after building your APK, there is an immediate output folder that contains the Android project that you can import and build from Eclipse after you've built from the UE4 editor. You can find the place in the output log. I didn't find it necessary to do this other than to quickly fix any Java errors in the plugin during development.

                        Comment


                          #13
                          i am not able to find the admob integration at the link provided .

                          Please provide the updated link for admob integration with unreal.

                          Comment


                            #14
                            Bumping this thread
                            Has anyone been able to use their own Java library in UE4 by the book? I need to use Android level gyroscope functions. Still looking for the solution.

                            Comment


                              #15
                              Originally posted by Kosmo View Post
                              Bumping this thread
                              Has anyone been able to use their own Java library in UE4 by the book? I need to use Android level gyroscope functions. Still looking for the solution.
                              Yes I've been able to add Java and native libraries to Unreal. I documented and checked in the source here.
                              https://github.com/ouya/docs/blob/master/unreal.md

                              Let me know if you have any questions.

                              Comment

                              Working...
                              X