* 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
이런 에러가 뜹니다.. 암만봐도 함수 형식은 문제 없어보이는데요... 문제가 뭘까요..??
답변 부탁드립니다. 몇일째 머리가 뽀개질것 같아요.. ㅡ.ㅡ