마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

java.lang.UnsatisfiedLinkError... 하~ 돌아버리겠습니다. 도와주세요..ㅡ.ㅡ

0 추천
* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
#include <android/log.h>

#include <GLES/gl.h>
#include <GLES/glext.h>

#define  LOG_TAG    "OpenGLTestJNI"
#define  LOGI(...)  __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
#define  LOGE(...)  __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)

extern "C"
{
    JNIEXPORT void JNICALL Java_com_opengl_test_JNILib_nativeCreated
    (JNIEnv *env, jclass cls);

    JNIEXPORT void JNICALL Java_com_opengl_test_JNILib_nativeChanged
    (JNIEnv *env, jclass cls, jint w, jint h);
    
    JNIEXPORT void JNICALL Java_com_opengl_test_JNILib_nativeUpdateGame
    (JNIEnv *env, jclass cls);
    
    JNIEXPORT void JNICALL Java_com_opengl_test_JNILib_nativeOnTouchEvent
    (JNIEnv *env, jclass cls, jint x, jint y, jint f);
}

JNIEXPORT void JNICALL Java_com_opengl_test_JNILib_nativeCreated(JNIEnv *env, jclass cls)
{
    LOGI("#### nativeCreated\n");
}

JNIEXPORT void JNICALL Java_com_opengl_test_JNILib_nativeChanged(JNIEnv *env, jclass cls, jint w, jint h)
{
    LOGI("#### nativeChanged\n");
}

JNIEXPORT void JNICALL Java_com_opengl_test_JNILib_nativeUpdateGame(JNIEnv *env, jclass cls)
{
    glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
    glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
    
    LOGI("#### nativeUpdateGame\n");
}

JNIEXPORT void JNICALL Java_com_opengl_test_JNILib_nativeOnTouchEvent(JNIEnv *env, jclass cls, jint x, jint t, jint f)
{
    LOGI("#### nativeOnTouchEvent\n");
}
com_opengl_test_JNILib.cpp 
 
 
 
 
public class JNILib
{
    static
    {
        System.loadLibrary("test");
    }

    public static native void nativeCreated();
    public static native void nativeChanged(int w, int h);
    public static native void nativeUpdateGame();
    public static native void nativeOnTouchEvent(int x, int y, int touchFlag);
}

JNILib.java

 

package com.opengl.test;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

import android.content.Context;
import android.opengl.GLSurfaceView;
import android.opengl.GLSurfaceView.Renderer;
import android.util.Log;
import android.view.MotionEvent;

public class GLView extends GLSurfaceView implements Renderer
{
    public GLView(Context context)
    {
        super(context);
        this.setRenderer(this);
        this.requestFocus();
        this.setRenderMode(RENDERMODE_CONTINUOUSLY);
        this.setFocusableInTouchMode(true);
    }

    @Override
    public void onDrawFrame(GL10 gl)
    {
        JNILib.nativeUpdateGame();
    }

    @Override
    public void onSurfaceChanged(GL10 gl, int width, int height)
    {
        JNILib.nativeChanged(width, height);
    }

    @Override
    public void onSurfaceCreated(GL10 gl, EGLConfig config)
    {
        JNILib.nativeCreated();
    }

    @Override
    public boolean onTouchEvent(MotionEvent event)
    {
        JNILib.nativeOnTouchEvent((int)event.getX(), (int)event.getY(), event.getAction());
        return true;
    }
}

GLview.java

 
apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.opengl.test"
        minSdkVersion 15
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"

        ndk {
            moduleName "test"
            ldLibs "GLESv1_CM", "android", "log", "z"
        }

        sourceSets.main{
            jni.srcDirs = []
            jniLibs.srcDir 'src/main/libs'
        }

        task buildNative(type: Exec, description: 'Compile JNI source via NDK') {
            def ndkDir = project.plugins.findPlugin('com.android.application').getNdkFolder()
            commandLine "$ndkDir/ndk-build",
                    '-C', file('src/main/jni').absolutePath,
                    '-j', Runtime.runtime.availableProcessors(),
                    'all',
                    'NDK_DEBUG=1'
        }

        task cleanNative(type: Exec, description: 'Clean JNI object files') {
            def ndkDir = project.plugins.findPlugin('com.android.application').getNdkFolder()
            commandLine "$ndkDir/ndk-build",
                    '-C', file('src/main/jni').absolutePath,
                    'clean'
        }

        clean.dependsOn 'cleanNative'

        tasks.withType(JavaCompile) {
            compileTask -> compileTask.dependsOn buildNative
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
}

build.gradle

 
 
D/dalvikvm﹕ Trying to load lib /data/data/com.opengl.test/lib/libtest.so 0xa6ae99a8
D/dalvikvm﹕ Added shared lib /data/data/com.opengl.test/lib/libtest.so 0xa6ae99a8
D/OpenGLRenderer﹕ TextureCache::get: create texture(0xb8954be8): name, size, mSize = 1, 1764, 1764
D/dalvikvm﹕ No JNI_OnLoad found in /data/data/com.opengl.test/lib/libtest.so 0xa6ae99a8, skipping i
W/dalvikvm﹕ No implementation found for native Lcom/opengl/test/JNILib;.nativeCreated:()V
W/dalvikvm﹕ threadid=11: thread exiting with uncaught exception (group=0xa6316288)
E/AndroidRuntime﹕ FATAL EXCEPTION: GLThread 195

java.lang.UnsatisfiedLinkError: Native method not found: com.opengl.test.JNILib.nativeCreated

이런 에러가 뜹니다.. 암만봐도 함수 형식은 문제 없어보이는데요... 문제가 뭘까요..??

답변 부탁드립니다. 몇일째 머리가 뽀개질것 같아요.. ㅡ.ㅡ

 

용맨소녀 (160 포인트) 님이 2015년 2월 16일 질문

답변 달기

· 글에 소스 코드 보기 좋게 넣는 법
· 질문에 대해 추가적인 질문이나 의견이 있으면 답변이 아니라 댓글로 달아주시기 바랍니다.
표시할 이름 (옵션):
개인정보: 당신의 이메일은 이 알림을 보내는데만 사용됩니다.
스팸 차단 검사:
스팸 검사를 다시 받지 않으려면 로그인하거나 혹은 가입 하세요.
...