Unfortunately, the JNI_OnLoad event seems like the ONLY time certain classes can be looked up. (I left some details about this in the previous post.)
Using the callback method and using a global variable constructor to register the JNI_OnLoad callback is fast enough to register the event and detect the classes successfully, all from a UE4 plugin.
There are some issues with bundling JAR/Java in a UE4 plugin, however. The Java and JAR file is not detected when provided by the plugin.
This is all so I can roll my Cortex/OUYA fork into a UE4 plugin. Developers don’t want to have to build the engine from source. Also as a plugin, it can be activated with the menu toggle.
I found one more issue. If I want to add android:game to the AndroidManifest.xml I need to make sure the APK is being built with API-21 or better build tools. How might I configure UE4 to do that? I’m already specifying a target version of 21. That should be enough.???
I am getting the expected manifest changes. It’s just the packaging tool needs to use the newer API???
Accessing JAR/Java from a UE4 plugin is working like a charm.
You can see I only needed to use FAndroidApplication::FindJavaClass from the UE4 StartupModule to be able to find classes from the JAR/Java. After finding the class I can use JNIEnv normally to find methods, fields, static methods, and invoke per the usual.
You can set the SDK API level to android-21 in Android SDK project settings in the editor. You can set it as high as android-22 if you have it installed, but do not set it to android-23 or android-24 yet; I need to update the APK expansion library code to remove depreciated APIs first.
Ah yes. That worked like a charm. I was looking in the Android project settings, but there’s the Android SDK project settings with NDK API Level which needed to be set to android-21. I did noticed when I saved changes that this setting doesn’t appear to serialize to disk.
And here is where I enabled the android:isGame setting.
With this input callback is where I pass the input to Java, pass it through a framework, and then return the remapped input back to the UE4 plugin. This allows games to publish in the Cortex store and as the framework adds support for new controllers, the games won’t need to republish to get all the new mappings.
With the PR request I’ve been able to intercept all the controller KeyEvent and MotionEvent input and redirect that to the UE4 plugin.
Would this information work with implementing Facebook or NativeX SDKs? I’m attempting to setup pay per install advertising but I’m having a terrible time at doing so. I’m starting to regret spending time learning the engine because it’s near impossible to profit off any mobile makings.
But what I’m referring to is an SDK, not specifically a plugin. To run pay-per-install ads on Facebook you need to use the Facebook SDK and activate your app when it starts
@Override
public void onCreate() {
super.onCreate();
FacebookSdk.sdkInitialize(getApplicationContext());
AppEventsLogger.activateApp(this);
}
They have a decent looking guide but I’m not sure how to import only the part of the SDK I need, and how to call the java code from UE4. If this thread covers that I can look more thoroughly through it; I’m still learning things here – so I wanted to know if my request is supported with this method before I go about researching it.
I’ll bookmark this page and potentially get around to it. Feels like I spend more time hacking things together than actual game designing. Maybe someone will make a plugin and throw it on the market for activating common pay-per-install services
jajaja Mr @tgraupmann you are a rock!, i dont know what can i do without your powers, thanks to you i understand quick the new system, i update my old plugin to access the camera now without modify the engine source, i never say thanks before, the new system is very cool now i can do what ever i want
hi tgraupmann right now unreal API cant access the camera, even with c++ is impossible, like the oficial android studio page says, this is only possible in java side, im using a Android View and pass my data to unreal, i read from some post, looks like some guy is integrating this, so maybe the android camera will be accesible from the oficial unreal API soon, meanwhile i have mine ^_^, really i dont know about the microphone, sounds like a great feature! i dont research about that in the unreal API
Media Framework 2.0 will allow for camera input sources. It may not be in 4.13 with first release but the necessary hooks will be in place. I have a plugin I did back with 4.10 using the existing media system, but it is a bit messy (it pretends to be a movie player for files with extension .acam and uses the filename for selecting camera, resolution, and framerate). I’ll update it to work with the new system soon.
hi [MENTION=11153] Babcock[/MENTION] so when we can spec to see that? in 4.14? im using the android.hardware.camera2 api right now, there is a way to access the camera from c++? or really is just java side? because sometime ago i research a lot, and i never see a example, but poeple on the wild internet told me this is posible with unofficial APIs, i made this in the early 4.5 i think, but when see this post i decide upgrade to use the android new plugin system based in GearVR plugin, i never use the media framework, i will take a look
If not in for 4.13, it will likely be available before 4.14 as a plugin. I used android.hardware.Camera in Java. Native camera APIs on Android are a mess (different APIs for different Android versions).
I tried to compile GitHub - tgraupmann/UE4_Plugin_Cortex_App_Store and it doesn’t.
After all fixes on CPP i have:
====6/17/2016 1:15:13 PM====PERFORMING FINAL APK PACKAGE OPERATION================================================
MainFrameActions: Packaging (Android (ATC)): mono: Making .apk with Ant… (note: it’s safe to ignore javac obsolete warnings)
MainFrameActions: Packaging (Android (ATC)): mono: Duplicated project name in import. Project custom_rules defined first in /Users/AlekseiKanash/Projects/UE4_Plugin_Cortex_App_Store/ExampleProject/Intermediate/Android/APK/custom_rules.xml and again in /Users/AlekseiKanash/Projects/UE4_Plugin_Cortex_App_Store/ExampleProject/Intermediate/Android/APK/JavaLibs/g
oogle-play-services_lib_rev19/custom_rules.xml
MainFrameActions: Packaging (Android (ATC)): mono: [javac] warning: [options] source value 1.5 is obsolete and will be removed in a future release
MainFrameActions: Packaging (Android (ATC)): mono: [javac] warning: [options] target value 1.5 is obsolete and will be removed in a future release
MainFrameActions: Packaging (Android (ATC)): mono: [javac] warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
MainFrameActions: Packaging (Android (ATC)): mono: [javac] 3 warnings
MainFrameActions: Packaging (Android (ATC)): mono: Duplicated project name in import. Project custom_rules defined first in /Users/AlekseiKanash/Projects/UE4_Plugin_Cortex_App_Store/ExampleProject/Intermediate/Android/APK/custom_rules.xml and again in /Users/AlekseiKanash/Projects/UE4_Plugin_Cortex_App_Store/ExampleProject/Intermediate/Android/APK/JavaLibs/d
ownloader_library/custom_rules.xml
MainFrameActions: Packaging (Android (ATC)): mono: [javac] warning: [options] source value 1.5 is obsolete and will be removed in a future release
MainFrameActions: Packaging (Android (ATC)): mono: [javac] warning: [options] target value 1.5 is obsolete and will be removed in a future release
MainFrameActions: Packaging (Android (ATC)): mono: [javac] warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
MainFrameActions: Packaging (Android (ATC)): mono: [javac] 3 warnings
MainFrameActions: Packaging (Android (ATC)): mono:
MainFrameActions: Packaging (Android (ATC)): mono: BUILD FAILED
MainFrameActions: Packaging (Android (ATC)): mono: /Users/AlekseiKanash/NVPACK/android-sdk-macosx/tools/ant/build.xml:649: The following error occurred while executing this line:
MainFrameActions: Packaging (Android (ATC)): mono: /Users/AlekseiKanash/NVPACK/android-sdk-macosx/tools/ant/build.xml:694: null returned: 1
MainFrameActions: Packaging (Android (ATC)): mono:
MainFrameActions: Packaging (Android (ATC)): mono: Total time: 2 seconds
MainFrameActions: Packaging (Android (ATC)): mono: UnrealBuildTool Exception: ERROR: /bin/sh failed with args -c ‘"/Users/AlekseiKanash/NVPACK/apache-ant-1.9.7/bin/ant" -quiet debug’
MainFrameActions: Packaging (Android (ATC)): CommandUtils.Run: Run: Took 6.539012s to run mono, ExitCode=5