나는 NDK와 c, C++가 처음이다. 그래서 내가 잘못하면 나를 용서해주십시오.Android-NDK "java.lang.UnsatisfiedLinkError"
는 내가 무엇입니까 로그인 고양이의 오류가 나는 lib 폴더에libfirst-opengl.so
라이브러리를 볼 수 있습니다 NDK 빌드 후
java.lang.UnsatisfiedLinkError
이
들으은 JAVA에 대한 내 코드입니다
public class MainActivity extends Activity {
private GLSurfaceView mGLSurfaceView;
/** Called when the activity is first created. */
static{
System.loadLibrary("first-opengl");
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set window full screen and remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
// Create the EGL surface (set OpenGL version 2.0) and override the
// renderer with our custom one
mGLSurfaceView = new GLSurfaceView(this);
mGLSurfaceView.setEGLContextClientVersion(2);
mGLSurfaceView.setRenderer(new MySurfaceViewRenderer());
setContentView(mGLSurfaceView);
}
@Override
public void onPause() {
super.onPause();
mGLSurfaceView.onPause();
}
@Override
public void onResume() {
super.onResume();
mGLSurfaceView.onResume();
}
public class MySurfaceViewRenderer implements Renderer {
public void onSurfaceCreated(GL10 unused, EGLConfig config) {
JNIOnSurfaceCreated();
}
public void onSurfaceChanged(GL10 unused, int w, int h) {
JNIOnSurfaceChanged(w, h);
}
public void onDrawFrame(GL10 unused) {
JNIOnDrawFrame();
}
private native void JNIOnSurfaceCreated();
private native void JNIOnSurfaceChanged(int w, int h);
private native void JNIOnDrawFrame();
}
}
코드 C에 대한 ++ 파일입니다
..
#include <jni.h>
#include <string.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <stdio.h>
#include <stdlib.h>
#include <android/log.h>
#define LOG_TAG "opengl-first"
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
void surfaceCreated(){
const GLubyte* puiOpenGLVersion = glGetString(GL_VERSION);
LOGI("OpenGL Version: \"%s\"\n", (char*)puiOpenGLVersion);
}
void surfaceChanged(int w, int h){
LOGI("JNIOnSurfaceChanged %dx%d\n", w, h);
glViewport(0, 0, w, h);
}
void drawFrame(){
// Clear the screen to a random shade of grey
float fColor = (float)(rand() % 256)/255.0f;
glClearColor(fColor, fColor, fColor, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
}
extern "C" {
JNIEXPORT void JNICALL Java_com_nix_opendk_MainActivity_JNIOnDrawFrame(JNIEnv* env, void* reserved);
JNIEXPORT void JNICALL Java_com_nix_opendk_MainActivity_JNIOnSurfaceChanged(JNIEnv* env, void* reserved, int w, int h);
JNIEXPORT void JNICALL Java_com_nix_opendk_MainActivity_JNIOnSurfaceCreated(JNIEnv* env, void* reserved);
};
JNIEXPORT void JNICALL Java_com_nix_opendk_MainActivity_JNIOnSurfaceCreated(JNIEnv* env, void* reserved)
{
surfaceCreated();
}
JNIEXPORT void JNICALL Java_com_nix_opendk_MainActivity_JNIOnSurfaceChanged(JNIEnv* env, void* reserved, int w, int h)
{
surfaceChanged(w,h);
}
JNIEXPORT void JNICALL Java_com_nix_opendk_MainActivity_JNIOnDrawFrame(JNIEnv* env, void* reserved)
{
drawFrame();
}
내 메이크업 파일 : -
내가 추가 한 있도록LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_LDLIBS := -llog -lGLESv2
LOCAL_CFLAGS := -Werror
LOCAL_MODULE := first-opengl
LOCAL_SRC_FILES := opengl-first.cpp
include $(BUILD_SHARED_LIBRARY)
내가 오류를 genrating되는 부분을 인식하지 않았다 내 모든 코드
이 저를 도와주세요.
이JNIEXPORT void JNICALL Java_com_nix_opendk_MainActivity_JNIOnDrawFrame
아마해야합니다 :
하지 MainActivity 때문에 MySurfaceViewRenderer 렌더러 클래스에있는 당신
몇 가지 질문이 있습니다. 1. 어떤 Android API를 사용하고 있습니까? 2. APK에 lib 폴더에 "libfirst-opengl.so"가 있습니까? (APK를 zip 아카이브로 열 수 있음). 3. 프로젝트 속성 (속성 -> android-> library)에 opengl lib를 포함 시켰습니까? 또한'jni/Application.mk' 파일에서'APP_ABI : = armeabi-v7a'을'APP_ABI : = armeabi'로 변경하십시오. 실제 나는 [비슷한 문제가] (http://stackoverflow.com/questions/10857301/unable-to-link-native-library-in-opencv-android-sample)하지만 아직 수정하지 않았습니다 : ( – ArtemStorozhuk
1) 나는 2.3.3을 사용하고있다. 2) 예, 거기에있다. 3) NDK의 샘플을 보았고, 그런 라이브러리도 포함하지 않았다. –