Не найдена реализация для int org.libsdl.app.SDLActivity.nativeSetupJNI () - PullRequest
1 голос
/ 28 апреля 2019

Прежде всего, хочу подтвердить, что просмотрел все похожие темы и не нашел ничего, что могло бы решить мою проблему. Когда я хочу запустить приложение на моем телефоне, он выдает UnsatisfiedLinkError и не находит реализации для int org.libsdl.app.SDLActivity.nativeSetupJNI ().

04-28 16:56:13.081 17793 17793 E art     : No implementation found for int org.etlegacy.app.SDLActivity.nativeSetupJNI() (tried Java_org_etlegacy_app_SDLActivity_nativeSetupJNI and Java_org_etlegacy_app_SDLActivity_nativeSetupJNI__)
04-28 16:56:13.082 17793 17793 D AndroidRuntime: Shutting down VM
04-28 16:56:13.082 17793 17793 E AndroidRuntime: FATAL EXCEPTION: main
04-28 16:56:13.082 17793 17793 E AndroidRuntime: Process: org.etlegacy.app, PID: 17793
04-28 16:56:13.082 17793 17793 E AndroidRuntime: java.lang.UnsatisfiedLinkError: No implementation found for int org.etlegacy.app.SDLActivity.nativeSetupJNI() (tried Java_org_etlegacy_app_SDLActivity_nativeSetupJNI and Java_org_etlegacy_app_SDLActivity_nativeSetupJNI__)
04-28 16:56:13.082 17793 17793 E AndroidRuntime:    at org.etlegacy.app.SDLActivity.nativeSetupJNI(Native Method)
04-28 16:56:13.082 17793 17793 E AndroidRuntime:    at org.etlegacy.app.SDL.setupJNI(SDL.java:15)
04-28 16:56:13.082 17793 17793 E AndroidRuntime:    at org.etlegacy.app.SDLActivity.onCreate(SDLActivity.java:234)
04-28 16:56:13.082 17793 17793 E AndroidRuntime:    at android.app.Activity.performCreate(Activity.java:6857)
04-28 16:56:13.082 17793 17793 E AndroidRuntime:    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
04-28 16:56:13.082 17793 17793 E AndroidRuntime:    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2676)
04-28 16:56:13.082 17793 17793 E AndroidRuntime:    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2784)
04-28 16:56:13.082 17793 17793 E AndroidRuntime:    at android.app.ActivityThread.-wrap12(ActivityThread.java)
04-28 16:56:13.082 17793 17793 E AndroidRuntime:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1523)
04-28 16:56:13.082 17793 17793 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:102)
04-28 16:56:13.082 17793 17793 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:163)
04-28 16:56:13.082 17793 17793 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:6238)
04-28 16:56:13.082 17793 17793 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
04-28 16:56:13.082 17793 17793 E AndroidRuntime:    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
04-28 16:56:13.082 17793 17793 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
04-28 16:56:13.091  3424  3645 D PowerKeeper.Event: notifyAMCrash packageName: 0, pid:17793

Безуспешно пытались добавить JNIEXPORT и JNICALL. Я предоставлю код из 3 разных файлов.

sys.android.c

#include "jni.h"
/*******************************************************************************
                 Functions called by JNI
*******************************************************************************/

/* Start up the ET Legacy app */
JNIEXPORT void JNICALL Java_org_etlegacy_app_SDLActivity_nativeInit(JNIEnv *env, jobject obj)
{
    Android_JNI_SetupThread();

    SDL_SetMainReady();

    /* Run the application code! */
    char *argv[2];
    argv[0] = SDL_strdup("ET Legacy");
    // send r_fullscreen 0 with argv[1] because on fullscreen can cause some issues see: https://github.com/rafal1137/android-project/commit/d960cc244b17d8cc0d084f9c8dad9c1af4b2ba72#diff-b9bd293cfb066fe80c10d3fcdd0fd6cbL439
    argv[1] = 0;
    SDL_main(1, argv);

}

sys_main.c

/**
 * @brief SDL_main
 * @param[in] argc
 * @param[in] argv
 * @return
 */
int main(int argc, char **argv)
{
    char commandLine[MAX_STRING_CHARS] = { 0 };

    Sys_PlatformInit();

    // Set the initial time base
    Sys_Milliseconds();

#ifdef __APPLE__
    // This is passed if we are launched by double-clicking
    if (argc >= 2 && Q_strncmp(argv[1], "-psn", 4) == 0)
    {
        argc = 1;
    }
#endif

    Sys_ParseArgs(argc, argv);

#if defined(__APPLE__) && !defined(DEDICATED)
    // argv[0] would be /Users/seth/etlegacy/etl.app/Contents/MacOS
    // But on OS X we want to pretend the binary path is the .app's parent
    // So that way the base folder is right next to the .app allowing
    {
        char     parentdir[1024];
        CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
        if (!url)
        {
            Sys_Dialog(DT_ERROR, "A CFURL for the app bundle could not be found.", "Can't set Sys_SetBinaryPath");
            Sys_Exit(EXIT_FAILURE);
        }

        CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url);
        if (!url2 || !CFURLGetFileSystemRepresentation(url2, 1, (UInt8 *)parentdir, 1024))
        {
            Sys_Dialog(DT_ERROR, "CFURLGetFileSystemRepresentation returned an error when finding the app bundle's parent directory.", "Can't set Sys_SetBinaryPath");
            Sys_Exit(EXIT_FAILURE);
        }

        Sys_SetBinaryPath(parentdir);

        CFRelease(url);
        CFRelease(url2);
    }
#else
    Sys_SetBinaryPath(Sys_Dirname(argv[0]));
#endif

    Sys_SetDefaultInstallPath(DEFAULT_BASEDIR); // Sys_BinaryPath() by default

    // Concatenate the command line for passing to Com_Init
    Sys_BuildCommandLine(argc, argv, commandLine, sizeof(commandLine));

    Com_Init(commandLine);
    NET_Init();

    Sys_SetUpConsoleAndSignals();

#ifdef _WIN32

#ifndef DEDICATED
    if (com_viewlog->integer)
    {
        Sys_ShowConsoleWindow(1, qfalse);
    }
#endif

    Sys_Splash(qfalse);

    {
        char cwd[MAX_OSPATH];
        _getcwd(cwd, sizeof(cwd));
        Com_Printf("Working directory: %s\n", cwd);
    }

    // hide the early console since we've reached the point where we
    // have a working graphics subsystems
#ifndef LEGACY_DEBUG
    if (!com_dedicated->integer && !com_viewlog->integer)
    {
        Sys_ShowConsoleWindow(0, qfalse);
    }
#endif

#endif

    Sys_GameLoop();

    return EXIT_SUCCESS;
}

SDLActivity.java

protected String[] getLibraries() {
        return new String[] {
            "SDL2",
            "hidapi",
            "etl"
        };
    }

Должен ли я удалить SDL_main (1, argv); из файла sys_android.c, чтобы он мог выбрать правильный файл из sys_main.c?

1 Ответ

0 голосов
/ 30 апреля 2019

Проблема, кажется, опечатка в названии функции, правильной является Java_org_etlegacy_app_SDLActivity_nativeSetupJNI ()

...