Announcement

Collapse
No announcement yet.

Getting Started: Android Development References - Documentation Feedback

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

    Getting Started: Android Development References - Documentation Feedback

    I am referring to the Getting Started: Android Development guide.
    https://forums.unrealengine.com/show...ent-References

    I'd like to see more documentation around some key things.

    1) AndroidManifest.xml

    In my case I need to be able to alter the AndroidManfest.xml to add an intent filter to show in the OUYA play section.

    I'm able to build and run Unreal Engine 4.5.1 on the OUYA with File->Package Project->Android->Android (DXT).

    I'd like to add a category to the activity's intent-filter list like this.
    https://github.com/ouya/ouya-sdk-exa...nifest.xml#L22

    Maybe there's a way to add a configuration? Otherwise the alternative is to unpack the build with apktool to edit the manifest. That workaround is not ideal, it would be great to build it correctly the first time.

    2) APK size building a scene with a camera, light, and cube comes out to be 54MB. Any documentation on how to turn on build stripping to get the size down would be ideal.

    3) JNI - I'm looking for documentation on how to include the ouya-sdk.jar into the Unreal build. In addition to that an Android sample that uses JNI (finding Java classes in C++ and hooking the JNI_Onload routines) would be super helpful.

    Here's an example of what that looks like:
    https://github.com/ouya/ouya-sdk-exa...i/main.cpp#L25

    "JNI_OnLoad" is the entry point when a native library is loaded. You have a single opportunity to cache your Java classes so they can be invoked from C++.

    From JNI_Onload that gives me access to add in-app-purchasing access for the OUYA. I use that to get product details, make purchases, check receipts, etc.

    After installing TADP (referenced here https://docs.unrealengine.com/latest...nce/index.html) Visual Studio has templates for the setup I'm looking for.

    In Visual Studio 2013:
    File->New Project->Templates->Android->Android Hello World Demo - A project for creating an Android application that uses Java and native code to print "Hello World".

    I'm looking for documentation around using Java and native code in the Unreal project.

    4) I'd like to see some documentation about including assets and resources.

    My IAP sample app needs to include a signing key asset in the assets folder.
    https://github.com/ouya/ouya-sdk-exa...assets/key.der

    And then in the res/drawable folder I need to be able to place a custom icon 96x96.
    https://github.com/ouya/ouya-sdk-exa...e/app_icon.png

    And in res/drawable-xhdpi I need to be able to place a larger store icon 732x412.
    https://github.com/ouya/ouya-sdk-exa.../ouya_icon.png

    Again apktool can decode the APK, add these files, and repackage. But looking for docs to customize these during the initial build process.

    5) If the Android manifest could be modified, the application could start with an alternative activity, load Java and native libraries, and then load the Unreal GameActivity.java.

    Package=com.epicgames.VirtualController cmp=com.epicgames.VirtualController/com.epicgames.ue4.GameActivity

    6) Part of editing the AndroidManifest.xml more info on setting the package identifier would be useful. The package name seems to default to "com.epicgames.ProjectName".

    Thanks,

    ~Tim Graupmann
    Last edited by tgraupmann; 11-13-2014, 10:08 PM.

    #2
    Most of the standard Android customizations can be done in the install folder, I.e.
    C:\Program Files\Unreal\Epic Games\4.5\Engine\Build\Android\Java

    * Just personal preference, but I really try to avoid making changes to "Program Files" folders when making plugins. Ideally these Java customizations that follow will be part of the Unreal Project in the future.

    Epic Games\4.5\Engine\Build\Android\Java\AndroidManifest.xml - Here the package name can be customized.

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.epicgames.${EXECUTABLE_NAME}"


    And the intent filter can be added.

    <category android:name="tv.ouya.intent.category.GAME" />

    The default icon can be set.

    <application
    android:icon="@drawable/app_icon"


    The custom icons can be placed in:
    Epic Games\4.5\Engine\Build\Android\Java\res\drawable\app_icon.png
    Epic Games\4.5\Engine\Build\Android\Java\res\drawable-xhdpi\ouya_icon.png

    The signing key can be placed in:
    Epic Games\4.5\Engine\Build\Android\Java\assets\key.der

    The OUYA SDK can be placed in:
    Epic Games\4.5\Engine\Build\Android\Java\libs\ouya-sdk.jar

    The native plugin can be placed in:
    Epic Games\4.5\Engine\Build\Android\Java\libs\armeabi\lib-ouya-ndk.so
    Epic Games\4.5\Engine\Build\Android\Java\libs\x86\armeabi-v7a
    Epic Games\4.5\Engine\Build\Android\Java\libs\x86\lib-ouya-ndk.so

    Edit Epic Games\4.5\Engine\Build\Android\Java\libs\Android.mk to add the native library:

    include $(CLEAR_VARS)
    LOCAL_MODULE := -ouya-ndk
    LOCAL_SRC_FILES := lib-ouya-ndk.so
    include $(PREBUILT_SHARED_LIBRARY)


    Loading the native library can be called from:
    Epic Games\4.5\Engine\Build\Android\Java\src\com\epicgames\ue4\GameActivity.java

    static {
    System.loadLibrary("-ouya-ndk");
    }
    Last edited by tgraupmann; 11-14-2014, 07:33 PM.

    Comment


      #3
      Placing files into the following folders includes as expected:
      Epic Games\4.5\Engine\Build\Android\Java\assets\
      Epic Games\4.5\Engine\Build\Android\Java\res\drawable\
      Epic Games\4.5\Engine\Build\Android\Java\res\drawable-xhdpi\

      Placing the ouya-sdk.jar gets dexified
      Epic Games\4.5\Engine\Build\Android\Java\libs\ouya-sdk.jar

      Placing the Native library put one in the jni folder so the build process completes:
      Epic Games\4.5\Engine\Build\Android\Java\jni\lib-ouya-ndk.so

      And then put one in the standard Android place:
      Epic Games\4.5\Engine\Build\Android\Java\libs\armeabi\lib-ouya-ndk.so

      And then you'll see the JNI_OnLoad fire as expected:

      D/dalvikvm(24309): Trying to load lib /data/data/com.epicgames.VirtualController/lib/lib-ouya-ndk.so 0x41f27320
      D/dalvikvm(24309): Added shared lib /data/data/com.epicgames.VirtualController/lib/lib-ouya-ndk.so 0x41f27320
      I/jni.cpp (24309): JNI_OnLoad
      Last edited by tgraupmann; 11-15-2014, 12:25 AM.

      Comment


        #4
        I've needed to run the TADP 2.X version that comes with Unreal. Unfortunately this version is limited as it doesn't setup my Visual Studio properly with the templates needed for Android development. Of course it's the only way to get File->Package in Unreal to work with this 2.X version.

        https://developer.nvidia.com/tegra-a...velopment-pack

        Versus the 3.X version which properly sets up my VS 2012 and VS 2013 templates for proper Java and Native development. Is there a timeline when Unreal will support 3.X?

        Comment


          #5
          I've made an isolated project for a NativeActivity where I detect native input, route that input to Java, remap the input with the OUYA-sdk.jar, and then pass the remapped input back to native code.
          https://github.com/ouya/ouya-sdk-exa...ivityOuyaInput

          Now I need to know where the UE4 Input processing happens.

          The NDK samples usually show something like:

          /**
          * Process the next input event.
          */
          static int32_t engine_handle_input(struct android_app* app, AInputEvent* event) {

          Or:

          void android_main(struct android_app* state) {

          struct engine engine;

          // Make sure glue isn't stripped.
          app_dummy();

          memset(&engine, 0, sizeof(engine));
          state->userData = &engine;
          state->onAppCmd = engine_handle_cmd;
          state->onInputEvent = engine_handle_input;

          Even the NativeActivity documentation uses "engine_handle_input":
          http://developer.android.com/referen...eActivity.html

          Now I'm wondering where this routine happens in UE4. Will I need to search the github source and will it be something I can override or will I need to modify the engine?

          Thanks.


          Since logcat is showing:

          D/UE4 ( 2567): Received keycode: 96
          D/UE4 ( 2567): Received gamepad button: 96

          Most likely the input is being handled in:
          lib\armeabi-v7a\libUE4.so

          So I'll dive into that native code...


          Here's an area for documentation.

          libUE4.so - This is where the awesome Native Android logic happens -
          https://docs.unrealengine.com/latest...tation&x=0&y=0


          And... here is where the input handling is coming in.
          https://github.com/EpicGames/UnrealE...nchAndroid.cpp

          Input is coming in through a method called "HandleInputCB" part of LaunchAndroid.cpp.
          Last edited by tgraupmann; 11-19-2014, 11:27 PM.

          Comment


            #6
            I'm looking for some tips when I edit:
            https://github.com/EpicGames/UnrealE...nchAndroid.cpp

            I've found I need to rebuild the Solution->Engine->UE4 in Visual Studio to regenerate the code that builds libUE4.so.

            Is there a faster way to make changes and a specific project I can rebuild versus rebuilding the entire editor?

            Also another note:

            #include "LaunchPrivatePCH.h"

            LaunchPrivatePCH.h needs to be the first include in any cpp files that you add to the libUE4.so.



            This is a faster way to at least find your native C++ compiler mistakes faster:

            cd C:\unreal\UnrealEngine\Engine\Binaries\DotNET
            UnrealBuildTool.exe VirtualController Android Development C:\ouya-sdk-examples\Unreal\VirtualController\VirtualController.uproject -noxge

            I've also seen the Unreal build output doesn't give you a nice stack trace for Java compile errors. But you can import the immediate files into an Eclipse Android project:
            C:\ouya-sdk-examples\Unreal\VirtualController\Intermediate\Android\APK

            And copy from: C:\ouya-sdk-examples\Unreal\VirtualController\Intermediate\Android\APK\google-play-services_lib_rev19\libs\google-play-services.jar

            to: C:\ouya-sdk-examples\Unreal\VirtualController\Intermediate\Android\APK\libs

            To isolate any Java errors that might be coming up.

            Success in my end though.

            Now I have native input passed to Java, remapped, and the remapped input is sent back to Unreal native code.

            Now it's time to learn how to hook up BluePrints to C++ code...

            https://docs.unrealengine.com/latest...iew/index.html

            https://docs.unrealengine.com/latest...ces/index.html
            Last edited by tgraupmann; 11-20-2014, 05:28 PM.

            Comment


              #7
              I made a video for my next question.


              I'm trying to get a class blueprint to call my C++ code.

              I posted the question in the UE4 answer hub.
              https://answers.unrealengine.com/que...blueprint.html

              I'm following the documentation section on Delegates.
              https://docs.unrealengine.com/latest...tes/index.html

              Solved: I needed to use BlueprintCallable on the UFUNCTION.
              Last edited by tgraupmann; 11-26-2014, 04:05 PM.

              Comment


                #8
                My next question is how do I call Android specific code from C++ Actor code.

                https://answers.unrealengine.com/que...or-c-code.html

                Edit: works!

                Just make sure the BluePrint is calling the event...

                At this point I can pass remapped input to BluePrints and use in the Tappy Chicken project.
                Last edited by tgraupmann; 11-26-2014, 06:15 PM.

                Comment


                  #9
                  The input mapping is working well at this point.



                  The next step will be adding OUYA In-App-Purchases.

                  Comment


                    #10
                    Now I'm just looking to find out how to share the fork.

                    https://answers.unrealengine.com/que...bscribers.html

                    Comment


                      #11
                      The OUYA Fork of UE4 is now accessible and here's the new OUYA documentation.
                      https://github.com/ouya/docs/blob/master/unreal.md

                      Comment

                      Working...
                      X