[英]AndroidJavaException: java.lang.ClassNotFoundException: Didn't find class “com.unity3d.player.ReflectionHelper”
I am trying to call some java method in OnAudioFilterRead
function body. 我试图在
OnAudioFilterRead
函数体中调用一些Java方法。
Here is the code segment. 这是代码段。
void OnAudioFilterRead(float[] data, int channels)
{
AndroidJNI.AttachCurrentThread();
if (ok)
{
if (obj == null)
{
obj = new AndroidJavaObject("com.xx.aop.media.av.GPUFrameCapturer");
Debug.Log(obj.Call<bool>("isRecording"));
}
}
}
When I build apk on Android platform. 当我在Android平台上构建apk时。
Always encountered this error. 总是遇到此错误。
06-13 15:20:51.981 20255-20388/com.MeiTu.XRay E/Unity:
06-13 15:20:51.981 20255-20388 / com.MeiTu.XRay E / Unity:
AndroidJavaException: java.lang.ClassNotFoundException: Didn't find class "com.unity3d.player.ReflectionHelper" on path: DexPathList[[directory "."], nativeLibraryDirectories=[/system/lib, /vendor/lib, /system/lib, /vendor/lib]]
AndroidJavaException:java.lang.ClassNotFoundException:在路径:DexPathList [[directory“。”],nativeLibraryDirectories = [/ system / lib,/ vendor / lib,/ system /下,找不到类“ com.unity3d.player.ReflectionHelper” lib,/ vendor / lib]]
java.lang.ClassNotFoundException: Didn't find class "com.unity3d.player.ReflectionHelper" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/system/lib, /vendor/lib, /system/lib, /vendor/lib]]
java.lang.ClassNotFoundException:在路径:DexPathList [[directory“。”],nativeLibraryDirectories = [/ system / lib,/ vendor / lib,/ system / lib,上找不到类“ com.unity3d.player.ReflectionHelper” /供应商/ LIB]]
The OnAudioFilterRead
function is called in another Thread
so it looks like you used AndroidJNI.AttachCurrentThread()
to make it possible to use AndroidJavaObject
from another Thread. OnAudioFilterRead
函数在另一个Thread
被调用,因此您似乎使用了AndroidJNI.AttachCurrentThread()
使得可以从另一个线程使用AndroidJavaObject
。 You also need to detach it. 您还需要分离它。 Call
AndroidJNI.DetachCurrentThread()
at the end of the OnAudioFilterRead
function: 在
OnAudioFilterRead
函数的末尾调用AndroidJNI.DetachCurrentThread()
:
void OnAudioFilterRead(float[] data, int channels)
{
AndroidJNI.AttachCurrentThread();
if (ok)
{
if (obj == null)
{
obj = new AndroidJavaObject("com.xx.aop.media.av.GPUFrameCapturer");
Debug.Log(obj.Call<bool>("isRecording"));
}
}
AndroidJNI.DetachCurrentThread()
}
If this doesn't work, initialize the AndroidJavaObject
outside the OnAudioFilterRead
function such as the Start
or Awake
function then use it in the OnAudioFilterRead
function like above. 如果这不起作用,请在
OnAudioFilterRead
函数(例如Start
或Awake
函数)之外初始化AndroidJavaObject
,然后在上述OnAudioFilterRead
函数中使用它。
AndroidJavaObject obj;
void Start()
{
obj = new AndroidJavaObject("com.xx.aop.media.av.GPUFrameCapturer");
}
void OnAudioFilterRead(float[] data, int channels)
{
AndroidJNI.AttachCurrentThread();
if (ok)
{
if (obj == null)
{
Debug.Log(obj.Call<bool>("isRecording"));
}
}
AndroidJNI.DetachCurrentThread()
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.