java.lang.UnsatisfiedLinkError: No implementation found for int com.myapp.SDLActivity.nativeSetupJNI()

When I run my app on emulator in Android studio in debian I get next error:

11-29 07:41:22.147 2583-2583/com.example.administrator.myapp E/art: No implementation found for int com.example.administrator.myapp.SDLActivity.nativeSetupJNI() (tried Java_com_example_administrator_myapp_SDLActivity_nativeSetupJNI and Java_com_example_administrator_myapp_SDLActivity_nativeSetupJNI__)
11-29 07:41:22.155 2583-2583/com.example.administrator.myapp E/AndroidRuntime: FATAL EXCEPTION: main
 	Process: com.example.administrator.myapp, PID: 2583
 	java.lang.UnsatisfiedLinkError: No implementation found for int com.example.administrator.myapp.SDLActivity.nativeSetupJNI() (tried Java_com_example_administrator_myapp_SDLActivity_nativeSetupJNI and Java_com_example_administrator_myapp_SDLActivity_nativeSetupJNI__)
	at com.example.administrator.myapp.SDLActivity.nativeSetupJNI(Native Method)
	at com.example.administrator.myapp.SDL.setupJNI(SDL.java:14)
	at com.example.administrator.myapp.SDLActivity.onCreate(SDLActivity.java:190)
	at android.app.Activity.performCreate(Activity.java:6679)
	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
 	at android.app.ActivityThread.-wrap12(ActivityThread.java)
 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
 	at android.os.Handler.dispatchMessage(Handler.java:102)
 	at android.os.Looper.loop(Looper.java:154)
 	at android.app.ActivityThread.main(ActivityThread.java:6119)
 	at java.lang.reflect.Method.invoke(Native Method)
 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

I am using SDL2-2.0.7, SDL2_image-2.0.2 and SDL2_mixer-2.0.2 and folder android-project as my start point for my project.

You need to not rename SDLActivity or change which package it’s in, because java will look for particular C functions needed to implement SDL based on both the class and package names. If you want your application to have a different class name, then you need to make a new class that derives from SDLActivity instead of renaming SDLActivity. That way, SDLActivity will still have the correct name and Java will find the correct functions. See http://blog.stuff-o-matic.com/post/2013/10/20/ASGP-s-Android-Port-Part-IV%3A-building-the-APK for some examples.

1 Like

I have changed only package name from “package org.libsdl.app;” to “package com.example.administrator.myapp;” in SDLActivity.java and other similar java-files which I have copied from android-project folder.
I still have this line:

public class SDLActivity extends Activity {

and in AndroidManifest.xml I have this:

<activity android:name="SDLActivity"

Into the file /SDL2/src/core/android/SDL_android.c I found a line:

#define SDL_JAVA_PREFIX org_libsdl_app

but in the file AndroidManifest.xml there is a line:

<!-- Replace org.libsdl.app with the identifier of your game below, e.g.
     com.gamemaker.game
-->

It seems I can’t change package name of my app from default ‘org.libsdl.app’, right?

@Jacob_Lifshay, thanks for useful advice.

You should create your own activity class that extends the SDL one. You can put your own class into any package and leave the SDL one where it is.

1 Like

Oops, that was already stated above. After that you should be able to use any applicationId/package name you want. Note that the package name from the manifest is actually overridden by the applicationId from the app/build.gradle file (if I recall correctly).

@ollika, thank you!
I have created now my own java-class and have changed package name into the AndroidManifest.xml file and it works.