I've gone back to revise the Android setup instructions. While most of it is still very relevant, but with SDK changes, and changes to Android Studio, the tutorials need rethinking.
Now while I wrote much of the newer material, going back to it, I was really going through the motions and there are some steps that did not make sense to me. Even though they were needed to get the orx library and demo projects compiled, I did not explain what the effect of those steps were.
The document I want to review is: http://orx-project.org/wiki/en/tutorials/setup_android
So if anyone with experience on the android can side can help with some questions to get me started:
- What is the difference between Android and Android-Native? My understanding is that "native" applications are c++ and therefore require ndk-build. Yet the non-native one uses ndk-build does too. I don't understand the difference in that case. If there is minimal difference in the two project types, do they actually follow the same set of instructions?
- The Orx android demo seems to be configured for SDK 25 according to their files. The latest Android Studio ships with SDK 28 and will not compile for a number of reasons. I assume the files must be altered by hand each time when a user installs Studio with a later version of the SDK. Installing the SDK seems to have helped with compiling, but there are other errors. Will deal with these in later posts.
- There is a project to build the orx library at: /orx/code/build/android. So what is the one at: /orx/extern/android for?
- When compiling the orx library using ndk-build command, and then using the install.bat to move them to the /orx/code/lib/static/android folder... why is there a later step of running "3. Import Orx Library project into Android Studio." in the above document? What does this step do with the already compiled orx library?
Comments
I have the same understanding. Native is using C++ while non-native is using Java. I've never used the non-native one, so I'm afraid I can't help you there.
Yes, upgrades are a manual process that was handled by @lydesik until now. We might have to find someone willing to maintain the Android target in the future.
Isn't the extern one the java activity and such?
I haven't started an Android project for about 3 years, so I'm afraid I don't remember what that did. I know that for updating I simply had to rebuild orx itself and not have to touch anything on the game's android studio project side.
Sorry for not being much help here. I've only made a single Android app and the setup was 3 years ago and has been long erased from my memory. I do remember that working with the Android pipeline wasn't the most pleasant experience, but that has probably improved since.
The only thing I can possibly think of, is that the native one doesn't use java bootstrap code (that starts the c++ program), but I really have no idea.
Ok so this is an ongoing maintenance thing, and we can expect to update the android projects for each SDK release.
According to the android docs: "An activity is a single, focused thing that the user can do. Almost all activities interact with the user, so the Activity class takes care of creating a window for you in which you can place your UI"
So this related to any orx android app like the demo, and perhaps acts like a template for user's own projects.
Ok so that makes sense. Use ndk-build to compile and install the latest version of the orx library, but not have to change whatever consumes it.
I'm still not 100% clear why there is an android studio step after compiling the orx library with ndk-build... unless that studio project acts as a loader for the library into the real android studio project (which is a user's project). Because I don't recall that you can directly use the ndk compiled library into your own app without the middle step.
Android users... we are floundering here.
Well think of it as the part that allows an orx application to have a window and a view. Similar to GLFW on desktop, for example.
I believe Android Studio now supports debugging native code, but I've never tried it myself.
I got success tonight, compiling the orx library with command line ndk-build, and then compiling the android-native project within Android Studio 3.1.3 / Internal ndk-build / SDK 25. Then managed to build an APK from the compile, and ran it on a device.
Working perfectly.
There is a pull request up for some minor fixes needed along the way. I can start documenting the native instructions now.
Thanks for the PR, I'll have a look at it tonight. So you still need to
ndk-build
orx from the command line? I thought that was now handled from Android Studio?ndk-build is still required for the orx library itself, but not for the demo, and presumably, not for your own projects too.
Loki's quote was:
But that's fine. So technically, ndk standalone is required, and also the version inside Android Studio is required two. Two versions. At least what I found so far. Might be possible to call the in-IDE version from commandline if the path is set up correctly.
I don't think there are two separate versions of NDKs, are there? I have the feeling there should be a way to have
ndk-build
run the engine's one if set properly in a Android Studio project, but that might not be something most users want as most people won't modify the engine itself.Probably not. They might resolve to the same binary. You can download it standalone, or download it within Studio. I'll be wiping everything to start over anyway and I'll see.
It's very likely Studio is simply not setting the environment variable.