ndk开发技巧

/data/local/tmp/

我们编译的Android可执行程序可以放入 /data/local/tmp/ 目录执行,但是可执行文件依赖so时,需要使用以下方式执行:

  1. 首先把so文件也push到/data/local/tmp/ 目录
  2. Then just set LD_LIBRARY_PATH to point at that directory:
LD_LIBRARY_PATH=. ./your_executable_file

获取jobject的className

    // First get the class object
    jmethodID mid = spEnv.get()->GetMethodID(cls, "getClass", "()Ljava/lang/Class;");
    jobject clsObj = spEnv.get()->CallObjectMethod(obj, mid);

    // Now get the class object's class descriptor
    cls = spEnv.get()->GetObjectClass(clsObj);

    // Find the getName() method on the class object
    mid = spEnv.get()->GetMethodID(cls, "getName", "()Ljava/lang/String;");

    // Call the getName() to get a jstring object back
    jstring strObj = (jstring)spEnv.get()->CallObjectMethod(clsObj, mid);

    // Now get the c string from the java jstring object
    const char* str = spEnv.get()->GetStringUTFChars(strObj, NULL);

    // Print the class name
    AJ_LOGE("Calling class is: %s", str);
    
    // Release the memory pinned char array
    // spEnv.get()->ReleaseStringUTFChars(strObj, str);
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容