我一直在尝试将Picovoice Porcupine(https://github.com/Picovoice/Porcupine)集成到为Unity中的ARMv7 Android构建的概念验证演示中。我正在尝试使用DllImport函数访问GitHub存储库中提供的ARMv7 .so库。该库似乎已正确加载(因为我没有收到DllNotFoundException),但是尝试调用本机函数时遇到了EntryPointNotFoundExceptions。我想我可能是在声明函数调用不正确-如果您可以帮助我看看我要去哪里,我将不胜感激!
我已经在下面添加了相关代码,以及我作为参考的Android演示中的Java本机调用。
Java参考:
private native long init(String modelFilePath, String[] keywordFilePaths, float[] sensitivities);
private native int process(long object, short[] pcm);
private native void delete(long object);
统一代码:
public class PorcupineManager : ScriptableObject {
...
[DllImport("pv_porcupine")]
private static extern long init(string modelFilePath, string[] keywordFilePaths, float[] sensitivities);
[DllImport("pv_porcupine")]
private static extern int process(long porcupineObjectId, short[] pcm);
[DllImport("pv_porcupine")]
private static extern void delete(long porcupineObjectId);
public void Init() {
porcupineObject = init(Path.Combine(Application.dataPath, modelPath), new string[] { Path.Combine(Application.dataPath, keywordPath)}, new float[] { sensitivity });
}
...
}
摘录自日志:
2018-10-16 17:51:06.654 19176-19208 / com.meowtek.commandandcontrol E / Unity:EntryPointNotFoundException:init 在(包装器托管到本地)PorcupineManager:init(string,string [],single []) 在/ Users / Ronan / Unity Projects / CommandAndControl / Assets / Scripts / Porcupine / PorcupineManager.cs:40中的PorcupineManager.Init()[0x0006e]中 在/ Users / Ronan / Unity Projects / CommandAndControl / Assets / Scripts / Porcupine / PorcupineTest.cs:17中的PorcupineTest + c__Iterator0.MoveNext()[0x0005d] 在/Users/builduser/buildslave/unity/build/Runtime/Export/Coroutines.cs:17
中的UnityEngine.SetupCoroutine.InvokeMoveNext(IEnumerator枚举器,IntPtr returnValueAddress)[0x00028]