Unsatisfiedlinkerror in android (eclipse)

后端 未结 3 1924
北恋
北恋 2021-01-01 00:36

I am trying to run a simple jni code in Android, But all I am getting Unsatisfiedlinkerror .

Here is my Java code:

package com.lipcap;

import androi         


        
3条回答
  •  离开以前
    2021-01-01 01:12

    I will give an another advice.I got this same error before but I solved this problem via "Android Native Development Kit Cookbook".Please note these statements;

    The native function must follow a specific pattern for a package name, class name, and method name.The package and class name must agree with the package and class name of the Java class from which the native method is called, while the method name must be the same as the method name declared in that Java class. This helps the Dalvik VM to locate the native function at runtime.Failing to follow the rule will result in UnsatisfiedLinkError at runtime.

    For example for above

    You need to change your function name like (don't use com.bla in the package names if you focus on NDK)

    #include
    #include
    #include
    
    JNIEXPORT jstring JNICALL Java_lipcap_example_MainActivity_sniff
    (JNIEnv *env, jobject obj){
           return env->NewStringUTF("This is Native");
    }
    

提交回复
热议问题