My SDL Android app no longer starts up: Failed to register native method

I’ve updated Android Studio to the latest version (4.0.1) and updated SDL to 2.0.12 and the latest SDL2_image, TTF and Mixer, but when I try and run my Android apps on the simulator they install but fail to start, or even hit the breakpoint I’ve set on my main() function. They all used to work with SDL 2.0.8 and Android Studio 3 so I’m not sure what I’ve overlooked in my updating. From the Run pane I get a lot of text but this seems to be the key to where it fails:

Failed to register native method in /data/app/com.windowsgames.moab-F65QwY01086qlCKiAGJjHA==/base.apk
E/SDL: Failed to register methods of org/libsdl/app/SDLActivity
A/zygote:] JNI DETECTED ERROR IN APPLICATION: JNI FindClass called with pending exception java.lang.NoSuchMethodError: no static or non-static method “Lorg/libsdl/app/SDLActivity;.nativeSetScreenResolution(IIIIIF)V”

and at the end of all the text is:

A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 8059 (ndowsgames.moab), pid 8059 (ndowsgames.moab)

Any help would be much appreciated!

Did you update also the java files ? you should have this nativeSetScreenResolution() both in the java side and the c side, with correct prototype/signature.

It can also happen that the compilation/build is incorrect.

Thanks for your reply Sylvain, I went to Control Panel | Java and clicked on ‘Update Now’ (and now I have Version 8 Update 261 installed) and rebooted Windows, but I’m still getting that same error. Is there any other place I have to update Java?

It can also happen that the compilation/build is incorrect.

I guess that’s my build settings within my project? Any thoughts on what I might need to tweak in there?

I meant: SDL java files:, and so on.

1 Like

Ahhh, thanks Sylvain! I’ve only ever followed Lazy Foo’s instructions on getting an Android app set up and never managed to update SDL for any of them. So, I guess what I need to do is simply copy those 4 .java files from the latest SDL download and write over the existing ones in the org\libsdl\app folder?

I guess that’s what happens when you first create the Android project, and when you do the ‘Import Project’ stage it copies those 4 .java files for you then?

I copied the 4 .java files over (as well as the new HIDevice… ones - dunno what they do) and I’m back up and running!

Sylvain, you are a star! Thank you very much!!!

You’re welcome. For Android you can as well use latest mercurial version which is very stable.

1 Like