找不到int org.libsdl.app.SDLActivity.nativeSetupJNI()的实现

问题描述 投票:1回答:1

首先要确认我浏览了所有类似的主题,发现没有什么可以解决我的问题。当我想在我的手机上运行应用程序时,它会抛出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;
}

SDL activity.Java

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

我应该删除SDL_main(1,argv);从sys_android.c文件,所以它可以从sys_main.c中选择正确的一个?

android c sdl-2
1个回答
0
投票

问题似乎是函数名称中的拼写错误一个是Java_org_etlegacy_app_SDLActivity_nativeSetupJNI()

© www.soinside.com 2019 - 2024. All rights reserved.