Log in or register to post comments

UnsatisfiedLinkError: getOpenGlEsVersionNative

August 13, 2012 - 11:57pm #1

Hello,

I'm implementing on Eclipse Indigo with Android 3.0.

I have configured my development systen and the sample app runs without any problems.

But I have integrated the sample code into an other app:

The activity, with which I start the AR modi is called: AugmentedRealitySpielinhaltActivity;

In Cygwin everything is great, as you can see:

http://imageshack.us/f/29/logcygwin.png/ - log cygwin

But when I want to start the application on my smartphone I get this error messages:

08-14 08:38:12.895: E/AndroidRuntime(14967): FATAL EXCEPTION: main
08-14 08:38:12.895: E/AndroidRuntime(14967): java.lang.UnsatisfiedLinkError: getOpenGlEsVersionNative
08-14 08:38:12.895: E/AndroidRuntime(14967):     at com.game.AugmentedRealitySpielinhalt.getOpenGlEsVersionNative(Native Method)
08-14 08:38:12.895: E/AndroidRuntime(14967):     at com.game.AugmentedRealitySpielinhalt.getInitalFlags(AugmentedRealitySpielinhalt.java:389)
08-14 08:38:12.895: E/AndroidRuntime(14967):     at com.game.AugmentedRealitySpielinhalt.onCreate(AugmentedRealitySpielinhalt.java:277)
08-14 08:38:12.895: E/AndroidRuntime(14967):     at android.app.Activity.performCreate(Activity.java:4465)
08-14 08:38:12.895: E/AndroidRuntime(14967):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1052)
08-14 08:38:12.895: E/AndroidRuntime(14967):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1932)
08-14 08:38:12.895: E/AndroidRuntime(14967):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1993)
08-14 08:38:12.895: E/AndroidRuntime(14967):     at android.app.ActivityThread.access$600(ActivityThread.java:127)
08-14 08:38:12.895: E/AndroidRuntime(14967):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1159)
08-14 08:38:12.895: E/AndroidRuntime(14967):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-14 08:38:12.895: E/AndroidRuntime(14967):     at android.os.Looper.loop(Looper.java:137)
08-14 08:38:12.895: E/AndroidRuntime(14967):     at android.app.ActivityThread.main(ActivityThread.java:4507)
08-14 08:38:12.895: E/AndroidRuntime(14967):     at java.lang.reflect.Method.invokeNative(Native Method)
08-14 08:38:12.895: E/AndroidRuntime(14967):     at java.lang.reflect.Method.invoke(Method.java:511)
08-14 08:38:12.895: E/AndroidRuntime(14967):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
08-14 08:38:12.895: E/AndroidRuntime(14967):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
08-14 08:38:12.895: E/AndroidRuntime(14967):     at dalvik.system.NativeStart.main(Native Method)

 

I have a QCAR_SDK_ROOT variable, I have cleaned my project, I have also refreshed my project after the build in cygwin, but I always get this error message for the getOpenGlEsVersionNative() method.

AugmentedRealitySpielinhaltActivity:

    public native int getOpenGlEsVersionNative();

    private int getInitalFlags() {
        // TODO Auto-generated method stub
        int flag = 0;
        if(getOpenGlEsVersionNative() == 1) {
            flag = QCAR.GL_11;
        }
        else {
            flag = QCAR.GL_20;
        }
        return flag;
    }

 

HappyTag.cpp:

JNIEXPORT int JNICALL
Java_com_game_AugmentedRealitySpielinhalt_getOpenGlEsVersionNative(JNIEnv *, jobject)
{
#ifdef USE_OPENGL_ES_1_1
    return 1;
#else
    return 2;
#endif
}

 

As you can see I haven't changed so much of your source code, but what can I do to run my application with your sample?

Please help me.

Thanks for all,

Viktoria

 

 

 

UnsatisfiedLinkError: getOpenGlEsVersionNative

November 28, 2013 - 12:39am #9

UnsatisfiedLinkError: getOpenGlEsVersionNative

November 27, 2013 - 11:33pm #8

hai can u tell me the procedure how u solved the issue

UnsatisfiedLinkError: getOpenGlEsVersionNative

October 11, 2013 - 2:08am #7

hi,

how were you able to solve this problem.? I have done everything as suggested  and so far nothing.

UnsatisfiedLinkError: getOpenGlEsVersionNative

August 28, 2012 - 4:28pm #6

I have solved the problem.

Thanks for your help. :-)

UnsatisfiedLinkError: getOpenGlEsVersionNative

August 24, 2012 - 4:32pm #5

I cannot find the wrong path.

All of the Java ImageTargets files are in the com.game package.

My JNI folder is also situated like yours, so it is hierarchially situated only under the App Folder called HappyTag.

The ImageTargets.java Activity is now AugmentedRealitySpielinhalt.java and the ImageTargetRenderer.java is now ImageRenderer.java.

ImageTargets.cpp -> HappyTag.cpp

CubeShaders.h = CubeShaders.h

Teapot.h = Teapot.h

Texture.cpp = Texture.cpp

SampleUtils.cpp -> Utils.cpp

SampleUtils.h -> Utils.h

 

These are my native Methos in HappyTag.cpp:

JNIEXPORT int JNICALL
Java_com_game_AugmentedRealitySpielinhalt_getOpenGlEsVersionNative(JNIEnv *, jobject)
{
#ifdef USE_OPENGL_ES_1_1
    return 1;
#else
    return 2;
#endif
}

JNIEXPORT int JNICALL
Java_com_game_AugmentedRealitySpielinhalt_switchDatasetAsap(JNIEnv *, jobject) {
    switchDataSet = true;
}

JNIEXPORT int JNICALL
Java_com_game_AugmentedRealitySpielinhalt_initTracker(JNIEnv *, jobject) {

    QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance();
    QCAR::Tracker * tracker = trackerManager.initTracker(QCAR::Tracker::IMAGE_TRACKER);

    if(tracker == NULL) {
        return 0;
    }

    return 1;

}

JNIEXPORT int JNICALL
Java_com_game_AugmentedRealitySpielinhalt_deInitTracker(JNIEnv *, jobject) {
    QCAR::TrackerManager& trackerManage = QCAR::TrackerManager::getInstance();
    trackerManage.deinitTracker(QCAR::Tracker::IMAGE_TRACKER);
}

JNIEXPORT int JNICALL
Java_com_game_AugmentedRealitySpielinhalt_loadTrackerData(JNIEnv *, jobject) {
    QCAR::TrackerManager& trackerM = QCAR::TrackerManager::getInstance();
    QCAR::ImageTracker* imageT = static_cast<QCAR::ImageTracker*>(trackerM.getTracker(QCAR::Tracker::IMAGE_TRACKER));

    if(imageT == NULL) {
        return 0;
    }

    dataSetStonesAndChips = imageT->createDataSet();

    if(dataSetStonesAndChips == 0) {
        return 0;
    }

    dataSetTarmac = imageT->createDataSet();
    if(dataSetTarmac == 0) {
        return 0;

    }

    if(!dataSetStonesAndChips->load("StonesAndChips.xml", QCAR::DataSet::STORAGE_APPRESOURCE)) {
        return 0;
    }

    if(!dataSetTarmac->load("Tarmac.xml", QCAR::DataSet::STORAGE_APPRESOURCE)) {
        return 0;
    }

    if(!imageT->activateDataSet(dataSetStonesAndChips)) {
        return 0;
    }

    return 1;
}

JNIEXPORT void JNICALL
Java_com_game_AugmentedRealitySpielinhalt_onQCARInitNative(JNIEnv *, jobject) {
    QCAR::registerCallback(&updateCallback);
}

JNIEXPORT void JNICALL
Java_com_game_ImageRenderer_renderFrame(JNIEnv *, jobject) {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    QCAR::State state = QCAR::Renderer::getInstance().begin();
    QCAR::Renderer::getInstance().drawVideoBackground();

#ifdef USE_OPENGL_ES_1_1
    // Set GL11 flags:
    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_NORMAL_ARRAY);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);

    glEnable(GL_TEXTURE_2D);
    glDisable(GL_LIGHTING);

#endif

    glEnable(GL_DEPTH_TEST);
    glEnable(GL_CULL_FACE);

    for(int i=0; i<state.getNumActiveTrackables(); i++) {
        const QCAR::Trackable* trackable = state.getActiveTrackable(i);
        QCAR::Matrix44F modelViewMatrix = QCAR::Tool::convertPose2GLMatrix(trackable->getPose());

        int index;

        if(strcmp(trackable->getName(), "chips")==0) {
            index = 0;
        }

        else if(strcmp(trackable->getName(), "stones")==0) {
            index = 1;
        }

        else {
            index = 2;
        }

        const Texture* const thisTexture = textures

    ;

    #ifdef USE_OPENGL_ES_1_1

        glMatrixMode(GL_PROJECTION);
        glLoadMatrixf(projectionMatrix.data);

        glMatrixMode(GL_MODELVIEW);
        glLoadMatrixf(modelViewMatrix.data);
        glTranslatef(0.f, 0.f, kObjectScale);
        glScalef(kObjectScale, kObjectScale, kObjectScale);

        glBindTexture(GL_TEXTURE_2D, thisTexture->textureID);
        glTexCoordPointer(2, GL_FLOAT, 0, (const GLvoid*) &teapotTexCoords[0]);
        glVertexPointer(3, GL_FLOAT, 0, (const GLvoid*) &teapotVertices[0]);
        glNormalPointer(GL_FLOAT, 0, (const GLvoid*) &teapotNormals[0]);
        glDrawElements(GL_TRIANGLES, NUM_TEAPOT_OBJECT_INDEX, GL_UNSIGNED_SHORT, (const GLvoid*) &teapotIndices[0]);

    #else

        QCAR::Matrix44F modelViewProjection;

        Utils::translatePoseMatrix(0.0f, 0.0f, kObjectScale, &modelViewMatrix.data[0]);
        Utils::scalePoseMatrix(kObjectScale, kObjectScale, kObjectScale, &modelViewMatrix.data[0]);
        Utils::multiplyMatrix(&projectionMatrix.data[0], &modelViewMatrix.data[0], &modelViewProjections.data[0]);

        glUseProgramm(shaderProgrammID);
        glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &teapotVertices[0]);
        glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &teapotNormals[0]);
        glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &teapotTexCoords[0]);

        glEnableVertexAttribArray(vertexHandle);
        glEnableVertexAttribArray(normalHandle);
        glEnableVertexAttribArray(textureCoordHandle);

        glActiveTexture(GL_TEXTURE0);
        glBlindTexture(GL_TEXTURE_2D, thisTexture->mTextureID);
        glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE, (GLfloat*) &modelViewProjections.data[0]);
        glDrawElements(GL_TRIANGLES, NUM_TEAPOT_OBJECT_INDEX, GL_UNSIGNED_SHORT, (const GLvoid*) &teapotIndices[0]);

        Utils::checkGLError("HappyTag renderFrame");

    #endif

        }

        glDisable(GL_DEPTH_TEST);

    #ifdef USE_OPENGL_ES_1_1
        glDisable(GL_TEXTURE_2D);
        glDisableClientState(GL_VERTEX_ARRAY);
        glDisableClientState(GL_NORMAL_ARRAY);
        glDisableClientState(GL_TEXTURE_COORD_ARRAY);

    #else
        glDisableVertexAttribArray(vertexHandle);
        glDisableVertexAttribArray(normalHandle);
        glDisableVertexAttribArray(textureCoordHandle);
    #endif

        QCAR::Renderer::getInstance().end();
    }

    void configureVideoBackground() {

        QCAR::CameraDevice& camera = QCAR::CameraDevice::getInstance();
        QCAR::VideoMode video = camera.getVideoMode(QCAR::CameraDevice::MODE_DEFAULT);

        QCAR::VideoBackgroundConfig videoConfig;
        videoConfig.mEnabled = true;
        videoConfig.mSynchronous = true;
        videoConfig.mPosition.data[0] = 0.0f;
        videoConfig.mPosition.data[1] = 0.0f;

        if(isActivityInPortraitMode == true) {

            videoConfig.mSize.data[0] = video.mHeight * (screenHeight / (float) video.mWidth);
            videoConfig.mSize.data[1] = screenHeight;

            if(videoConfig.mSize.data[0] < screenWidth) {

                videoConfig.mSize.data[0] = screenWidth;
                videoConfig.mSize.data[1] = screenWidth * (video.mWidth / (float) video.mHeight);

            }
        }

        else {

            videoConfig.mSize.data[0] = screenWidth;
            videoConfig.mSize.data[1] = video.mHeight * (screenWidth / (float) video.mWidth);

            if(videoConfig.mSize.data[1] < screenHeight) {

                videoConfig.mSize.data[0] = screenHeight * (video.mWidth / (float) video.mHeight);
                videoConfig.mSize.data[1] = screenHeight;
            }
        }

        QCAR::Renderer::getInstance().setVideoBackgroundConfig(videoConfig);
    }

    JNIEXPORT void JNICALL
    Java_com_game_AugmentedRealitySpielinhalt_initAppNative(JNIEnv* env, jobject obj, jint width, jint height) {

        screenWidth = width;
        screenHeight = height;

        jclass activityClass = env->GetObjectClass(obj);
        jmethodID getTextureCountMethodID = env->GetMethodID(activityClass, "getTextureCount", "()I");

        if(getTextureCountMethodID == 0) {
            return;
        }

        textureCount = env->CallIntMethod(obj, getTextureCountMethodID);

        if(!textureCount) {
            return;
        }

        textures = new Texture*[textureCount];

        /*routing ok? */
        jmethodID getTextureMethodID = env->GetMethodID(activityClass, "getTexture", "(I)Lcom/game/Texture;");

        if(getTextureMethodID == 0) {
            return;
        }

        for(int i=0; i<textureCount; i++) {
            jobject textureObject = env->CallObjectMethod(obj, getTextureMethodID, i);
            if(textureObject == NULL) {
                return;
            }

            textures[i] = Texture::create(env, textureObject);

        }
    }

    JNIEXPORT void JNICALL
    Java_com_game_AugmentedRealitySpielinhalt_deInitApplicationNative(JNIEnv* env, jobject obj) {

        if(textures != 0) {

            for(int i=0; i<textureCount; i++) {

                delete textures[i];
                textures[i] = NULL;

            }

            delete[] textures;
            textures = NULL;

            textureCount = 0;
        }
    }

    JNIEXPORT void JNICALL
    Java_com_game_AugmentedRealitySpielinhalt_startCamera(JNIEnv *, jobject) {

        if(!QCAR::CameraDevice::getInstance().init()) {

            return;

        }

        configureVideoBackground();

        if(!QCAR::CameraDevice::getInstance().selectVideoMode(QCAR::CameraDevice::MODE_DEFAULT)) {

            return;

        }

        if(!QCAR::CameraDevice::getInstance().start()) {

            return;

        }

        QCAR::TrackerManager& trackerManage = QCAR::TrackerManager::getInstance();
        QCAR::Tracker* imageTrack = trackerManage.getTracker(QCAR::Tracker::IMAGE_TRACKER);

        if(imageTrack != 0) {

            imageTrack->start();

        }
    }

    JNIEXPORT void JNICALL
    Java_com_game_AugmentedRealitySpielinhalt_stopCamera(JNIEnv *, jobject) {

        QCAR::TrackerManager& tracker = QCAR::TrackerManager::getInstance();
        QCAR::Tracker* image = tracker.getTracker(QCAR::Tracker::IMAGE_TRACKER);

        if(image != 0) {

            image->stop();

        }

        QCAR::CameraDevice::getInstance().stop();
        QCAR::CameraDevice::getInstance().deinit();
    }

    JNIEXPORT void JNICALL
    Java_com_game_AugmentedRealitySpielinhalt_setProjectionMatrix(JNIEnv *, jobject) {

        const QCAR::CameraCalibration& cameraCalibration = QCAR::CameraDevice::getInstance().getCameraCalibration();
        projectionMatrix = QCAR::Tool::getProjectionGL(cameraCalibration, 2.0f, 2000.0f);

    }

    JNIEXPORT void JNICALL
    Java_com_game_ImageRenderer_initRendering(JNIEnv* env, jobject obj) {

        glClearColor(0.0f, 0.0f, 0.0f, QCAR::requiresAlpha() ? 0.0f : 1.0f);

        for(int i=0; i<textureCount; i++) {

            glGenTextures(1, &(textures[i]->textureID));
            glBindTexture(GL_TEXTURE_2D, textures[i]->textureID);
            glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
            glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, textures[i]->width, textures[i]->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*) textures[i]->data);
        }

    #ifndef USE_OPENGL_ES_1_1

        shaderProgramID = Utils::createProgramFromBuffer(cubeMeshVertexShader, cubeFragmentShader);
        vertexHandle = glGetAtrribLocation(shaderProgramID, "vertexPosition");
        normalHandle = glGetAttribLocation(shaderProgramID, "vertexNormal");
        textureCoordHandle = glGetAttribLocation(shaderProgramID, "vertexTexCoord");
        mvpMatrixHandle = glGetUniformLocation(shaderProgrammID, "modelViewProjectionMatrix");

    #endif

    }

    JNIEXPORT void JNICALL
    Java_com_game_ImageRenderer_updateRendering(JNIEnv* env, jobject obj, jint width, jint height) {

        screenWidth = width;
        screenHeight = height;
        configureVideoBackground();

    }

     

    Thank you for your help. ;-)

    UnsatisfiedLinkError: getOpenGlEsVersionNative

    August 20, 2012 - 6:23pm #4

    If your log is confirming that the libraries are loading, this error may relate to your JNI signature.

    Here's a simple example of declaring and specifying JNI methods across java and C++ - http://stackoverflow.com/questions/6096355/no-implementation-found-for-native

    And here is a basic description of package naming and importing conventions, just in case  - http://stackoverflow.com/questions/3861716/how-to-call-a-method-of-a-class-kept-under-other-package

    UnsatisfiedLinkError: getOpenGlEsVersionNative

    August 17, 2012 - 1:14pm #3

    Yes, I applied the package name across my application and at the manifest file.

    I have also often cleaned the project.

    cutout of the manifest:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.game"
        android:versionCode="1"
        android:versionName="1.0" >

        <uses-sdk
            android:minSdkVersion="4"
            android:targetSdkVersion="11" />

        <uses-feature android:name="android.hardware.camera" />
        <uses-feature
            android:name="android.hardware.camera.front"
            android:required="false" />

        <uses-permission android:name="android.permission.CAMERA" />
        <uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
        <uses-permission android:name="android.permission.INTERNET" />
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
        <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
        <uses-permission android:name="android.permission.READ_PHONE_STATE" />

     

    These are the line of codes for loading the native libraries:   

    static {
            com.game.AugmentedRealitySpielinhalt.loadLibrary(NATIVE_LIB_QCAR);
            com.game.AugmentedRealitySpielinhalt.loadLibrary(NATIVE_LIB_SAMPLE);
        }

        public static boolean loadLibrary(String libraryName) {
            try {
                System.loadLibrary(libraryName);
                DebugLog.LOGI("INFO:"," Native library lib "+libraryName+" so loaded!");
                return true;
            } catch(UnsatisfiedLinkError error) {
                DebugLog.LOGI("ERROR:", "The library "+libraryName+" cannot be loaded!");
            } catch(SecurityException security) {
                DebugLog.LOGI("ERROR: ","The library lib "+libraryName+" so was not allowed to be loaded!");
            }
           
            return false;
        }

     

    I get this warning before the UnsatisiedLinkError appears:

    08-17 21:38:57.102: W/dalvikvm(13458): No implementation found for native Lcom/game/AugmentedRealitySpielinhalt;.getOpenGLEsVersionNative ()I

    Thanks for your help. You saving my life.

     

    UnsatisfiedLinkError: getOpenGlEsVersionNative

    August 14, 2012 - 9:39am #2

    That error is typically associated w/ missing libraries or forgetting to clean the project, but it appears that you've done that correctly.

    How are you loading the native libraries?

    See: lines 108, 109 and 808 in ImageTargets.java for an example of how to do this.

    And to confirm, you are applying the package name consistently across the code and manifest?

    Log in or register to post comments