MoonStorm's picture

Can't find the project that creates SDL2.jar for Android

I know the OpenTk dependencies are available as binaries from git, and that is appreciated, but I need to compile the SDL package myself.

Problem is, I can't find the bridge between SDL and OpenTk. The android-project in the SDL is just a skeleton, and it's missing the main module. The activity present in OpenTk.Android.SDL2 project in OpenTk relies on a Main method being exposed by a base class Android activity. Can anyone please share the code for the missing main module for SDL?


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

Download the SDL2 source code and check android-project/src/org/libsdl/app/SDLActivity.java. SDL2.jar is built from that.

Note that SDLActivity.java must match the version of libSDL2.so you are using.

MoonStorm's picture

I tried that, but that project doesn't compile. Specifically android-project\jni\src\Android.mk has the following line:

LOCAL_SRC_FILES = $(SDL_PATH)/src/main/android/SDL_android_main.c YourSourceHere.c

so straight out of the box that project fails the first stage compilation with NDK so without getting past this point I can't produce the jar.
Searching around I found people are providing implementation for a main file, so as I said that project is treated as a skeleton.

the Fiddler's picture

I just checked and I am indeed adding modifying SDL. In short:

  1. SDLActivity.java: declare an empty Main function (public void Main() { }). This is available through GameActivity.cs and can be overriden to point to the actual entry point of your application (useful when porting from/to the desktop.) This is what the ES11 sample does.
  2. SDL_android_main.c: use JNI to call the Main() function above.
  3. SDLActivity.java: comment out line 54 System.loadLibrary("main");, as this is no longer used
  4. Android.mk: remove YourSourceHere.c - our source is written in C# instead

I am building the native library with:

ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./Android.mk APP_PLATFORM=android-19 APP_ABI=armeabi
ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./Android.mk APP_PLATFORM=android-19 APP_ABI=x86

And SDL2.jar via a plain android library project in eclipse / adt.

winterhell's picture

Sorry for offtopic but can you build applications for android with OpeTK and/or C# without Xamarin?

the Fiddler's picture

There is dot42. The SDL2 version of OpenTK should be portable to that runtime with some effort.

winterhell's picture

Thanks I'll try it out. It's nice to be able to prototype without paying an expensive subscription.

MoonStorm's picture
the Fiddler wrote:

I just checked and I am indeed adding modifying SDL. In short:

  1. SDLActivity.java: declare an empty Main function (public void Main() { }). This is available through GameActivity.cs and can be overriden to point to the actual entry point of your application (useful when porting from/to the desktop.) This is what the ES11 sample does.
  2. SDL_android_main.c: use JNI to call the Main() function above.
  3. SDLActivity.java: comment out line 54 System.loadLibrary("main");, as this is no longer used
  4. Android.mk: remove YourSourceHere.c - our source is written in C# instead

I am building the native library with:

ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./Android.mk APP_PLATFORM=android-19 APP_ABI=armeabi
ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./Android.mk APP_PLATFORM=android-19 APP_ABI=x86

And SDL2.jar via a plain android library project in eclipse / adt.

Thanks for that. Will give it a try.

winterhell wrote:

Thanks I'll try it out. It's nice to be able to prototype without paying an expensive subscription.

Looks like the commercial license for dot42 is 399$, whilst the indie one for Xamarin is 299$, so you do the math. The only annoying limitation for Xamarin Indie is that you'd have to use Xamarin Studio, but I plan to use that strictly for the front-end, with the most back-end logic written and unit-tested in Visual Studio. Hopefully Xamarin will eventually come to their senses at some point and include VS support in the Indie plan.

I'd personally replace the entire Mono source with the MS implementation and just replace the bits that are platform specific, because the quality of Mono is shockingly bad. On the surface it's alright, but if you start to use some more advanced techniques, it starts to smell bad. I've got two serious bugs logged into their database since the beginning of last year. Hopefully this new partnership MS-Xamarin will infuse some quality into it, and eventually we'll see Mono dead, providing MS is serious about the new open-source trend for this beautiful language and framework.

winterhell's picture
MoonStorm wrote:

Looks like the commercial license for dot42 is 399$, whilst the indie one for Xamarin is 299$, so you do the math. The only annoying limitation for Xamarin Indie is that you'd have to use Xamarin Studio, but I plan to use that strictly for the front-end, with the most back-end logic written and unit-tested in Visual Studio. Hopefully Xamarin will eventually come to their senses at some point and include VS support in the Indie plan.

Those are valid points. And I'd like to defer such costs as much as possible. Dot42's free license allows VS support and at the same time useful for prototyping/freeware/portfolio.
Ideally only once I've played around with the platform and made the optimizations, with a game near completion, would I want/have to pay. If that is 6 months or more from now, there are chances for price drops or better alternatives. Not to mention that Xamarin's license is not one time payment. Not sure for Dot42's.