Xamarin.Android 引用so

在这里插入图片描述

[DllImport("sqleet", EntryPoint= "execute_test")] public static extern string execute_test(string path);
//java
[DllImport("native-lib", EntryPoint = "Java_com_km_demo_myapplication_MainActivity_stringFromJNI")] public extern static IntPtr stringFromJNI(IntPtr env, IntPtr thiz);
//java
[DllImport("hello", EntryPoint = "Java_com_km_demo_myapplication_hello_add")] //省略掉lib前缀和.so 后缀
//public static extern int add(IntPtr env, IntPtr thiz, int i, int j);

[DllImport("hello")] //省略掉lib前缀和.so 后缀
public static extern int add( int i, int j);

[DllImport("hello")] //省略掉lib前缀和.so 后缀
public static extern string getString(string str);

//java 字符串
var zz = stringFromJNI(System.IntPtr.Zero, System.IntPtr.Zero);
Java.Lang.String ss = Java.Lang.Object.GetObject(zz, JniHandleOwnership.TransferLocalRef);
//普通字符串
string str = getString("abc");

普通的

java

#include
#include

extern "C" JNIEXPORT jstring JNICALL Java_com_km_demo_myapplication_MainActivity_stringFromJNI(
JNIEnv* env,
jobject /* this */) {
std::string hello = "Hello from C++";
return env->NewStringUTF(hello.c_str());
}

//
// Created by Administrator on 2020/3/18.
//
/* DO NOT EDIT THIS FILE - it is machine generated */
#include
/* Header for class com_km_demo_myapplication_hello */

#ifndef _Included_com_km_demo_myapplication_hello
#define _Included_com_km_demo_myapplication_hello
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: com_km_demo_myapplication_hello
* Method: add
* Signature: (II)I
*/
JNIEXPORT jint JNICALL Java_com_km_demo_myapplication_hello_add
(JNIEnv *, jobject, jint i, jint j){
return i+j;
}

int add(int i, int j){
return i+j;
}
#ifdef __cplusplus
}
#endif
#endif



作者:yubulen

相关推荐

Android 屏幕适配总结

Android 屏幕适配总结

在这里插入图片描述

10个命令27个实例手把手带你彻底整明白Linux用户和组管理

【Linux】Ubuntu16.04 adb devices提示no permissions的解决方法

【Linux】Ubuntu16.04 adb devices提示no permissions的解决方法

win和linux下anaconda中pip 和 conda 换源加速

win和linux下anaconda中pip 和 conda 换源加速