Simple SDL project for Android tablet, howto?

Hi,

I am trying to run an SDL project on an Android tablet, using the Android ndk. Finally I succeeded to compile and install a simple SDL file, without errors or warnings. The app icon appeared, I started it, and then: black screen. I suppose that my SDL file is missing something, but I don’t know what. So my question is: how must the SDL code look, that will display e.g. a black square on a red background, with one touch point? No OpenGL, no animations, no sound, only SDL_Renderer used. I am using the newest software: SDL2, ARM tablet running Android 4.0. Until now, only the “Hello World” example worked as expected.

Thanks in advance.

wboe

It occurred to me that my SDL source code was not compiled at all, but after a fresh install of the SDL directory this problem appeared to be solved. Now the next hurdle is a linking problem at run time. The ‘adb logcat’ output always reports the following error:

Code:
E/AndroidRuntime( 1213): FATAL EXCEPTION: SDLThread
E/AndroidRuntime( 1213): java.lang.UnsatisfiedLinkError: nativeInit
E/AndroidRuntime( 1213): at org.libsdl.app.SDLActivity.nativeInit(Native Method)
E/AndroidRuntime( 1213): at org.libsdl.app.SDLMain.run(SDLActivity.java:408)
E/AndroidRuntime( 1213): at java.lang.Thread.run(Thread.java:856)

Who has a hint for me?

wboe

it looks like you don’t load the shared object - are you using the
activity class that comes with sdl?Am 23.08.2012 14:26, schrieb wboe:

It occurred to me that my SDL source code was not compiled at all, but
after a fresh install of the SDL directory this problem appeared to be
solved. Now the next hurdle is a linking problem at run time. The ‘adb
logcat’ output always reports the following error:

Code:
E/AndroidRuntime( 1213): FATAL EXCEPTION: SDLThread
E/AndroidRuntime( 1213): java.lang.UnsatisfiedLinkError: nativeInit
E/AndroidRuntime( 1213): at
org.libsdl.app.SDLActivity.nativeInit(Native Method)
E/AndroidRuntime( 1213): at
org.libsdl.app.SDLMain.run(SDLActivity.java:408)
E/AndroidRuntime( 1213): at java.lang.Thread.run(Thread.java:856)

Who has a hint for me?

wboe


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Hi Martin,
Shure I am using the activity class that comes with sdl. The contents of the directory /bin/classes/org/libsdl/app is:

Code:
R$attr.class
R$drawable.class
R$string.class
SDLActivity$2.class
SDLMain.class
R.class
R$layout.class
SDLActivity$1.class
SDLActivity.class
SDLSurface.class

wboe

2012/8/23 wboe <w.boeke at upcmail.nl>

**
Hi Martin,
Shure I am using the activity class that comes with sdl. The contents of
the directory **/bin/classes/org/libsdl/app is:

Code:

R$attr.class
R$drawable.class
R$string.class
SDLActivity$2.class
SDLMain.class
R.class
R$layout.class
SDLActivity$1.class
SDLActivity.class
SDLSurface.class

wboe

Can you post the full log of your app? You should be seeing a message about
loading libSDL2.so, if I recall correctly that’s where nativeInit is.–
Gabriel.

Hello Martin
The full logcat output was 75 lines, from start until stop of the app. That’s a bit much, so I filtered out all lines containing ‘sdl’:

Code:
I/ActivityManager( 127): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=org.libsd

l.app/.SDLActivity} from pid 346
I/ActivityManager( 127): Start proc org.libsdl.app for activity org.libsdl.app/.SDLActivity: pid=1441 uid=10052 gids={1015}
D/dalvikvm( 1441): Trying to load lib /data/data/org.libsdl.app/lib/libSDL2.so 0x41052300
D/dalvikvm( 1441): Added shared lib /data/data/org.libsdl.app/lib/libSDL2.so 0x41052300
D/dalvikvm( 1441): Trying to load lib /data/data/org.libsdl.app/lib/libmain.so 0x41052300
D/dalvikvm( 1441): Added shared lib /data/data/org.libsdl.app/lib/libmain.so 0x41052300
D/dalvikvm( 1441): No JNI_OnLoad found in /data/data/org.libsdl.app/lib/libmain.so 0x41052300, skipping init
V/SDL ( 1441): surfaceCreated()
V/SDL ( 1441): surfaceChanged()
V/SDL ( 1441): pixel format RGB_565
V/SDL ( 1441): Window size:320x484
W/dalvikvm( 1441): No implementation found for native Lorg/libsdl/app/SDLActivity;.nativeInit ()V
E/AndroidRuntime( 1441): FATAL EXCEPTION: SDLThread
E/AndroidRuntime( 1441): at org.libsdl.app.SDLActivity.nativeInit(Native Method)
E/AndroidRuntime( 1441): at org.libsdl.app.SDLMain.run(SDLActivity.java:408)
W/ActivityManager( 127): Force finishing activity org.libsdl.app/.SDLActivity
I/ActivityManager( 127): Displayed org.libsdl.app/.SDLActivity: +345ms
V/SDL ( 1441): surfaceDestroyed()
V/SDL ( 1441): surfaceCreated()
V/SDL ( 1441): onDestroy()
W/ActivityManager( 127): Activity destroy timeout for ActivityRecord{41243d00 org.libsdl.app/.SDLActivity}

As can be seen, /libSDL2.so was loaded correctly.

wboe

This is an addendum to my last post.
The essential error message from the logcat output is

Code:
W/dalvikvm( 1441): No implementation found for native Lorg/libsdl/app/SDLActivity;.nativeInit ()V

This must be the problem. Indeed nowhere on my hard disk there is something like nativeInit.class. Which script or program should be responsible for this?

wboe

2012/8/23 wboe <w.boeke at upcmail.nl>

**
This is an addendum to my last post.
The essential error message from the logcat output is

Code:

W/dalvikvm( 1441): No implementation found for native
Lorg/libsdl/app/SDLActivity;.nativeInit ()V

This must be the problem. Indeed nowhere on my hard disk there is
something like nativeInit.class. Which script or program should be
responsible for this?

If you look at SDLActivity.java, you’ll see on line 149:

// C functions we call
public static native void nativeInit();
public static native void nativeQuit();
public static native void nativePause();
public static native void nativeResume();

Those functions on the C side of the code are
called Java_org_libsdl_app_SDLActivity_ so nativeInit would
be Java_org_libsdl_app_SDLActivity_nativeInit which is located in
src/main/android/SDL_android_main.cpp

// Start up the SDL app
extern “C” void Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env,
jclass cls, jobject obj)

I’ll start by making sure you have libSDL2.so and libmain.so in your
<android_project>/libs/armeabi after you go through the build process.–
Gabriel.

Hi Gabriel,

I’ll start by making sure you have libSDL2.so and libmain.so in your <android_project>/libs/armeabi after you go through the build process.

Both files are there! Their time stamps are 2012-08-23 15:09, so that’s okay.

wboe