简体   繁体   English

AndroidJavaException:java.lang.ClassNotFoundException:找不到类“ com.unity3d.player.ReflectionHelper”

[英]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函数(例如StartAwake函数)之外初始化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.

相关问题 AndroidJavaException:java.lang.ClassNotFoundException:com.google.unity.ads.UnityInterstitialAdCallback - AndroidJavaException: java.lang.ClassNotFoundException: com.google.unity.ads.UnityInterstitialAdCallback Java.Lang.ClassNotFoundException:找不到类“ android.view.CoordinatorLayout” - Java.Lang.ClassNotFoundException: Didn't find class “android.view.CoordinatorLayout” AndroidRuntime引起原因:java.lang.ClassNotFoundException:找不到类“ android.support.multidex.MultiDexApplication” - AndroidRuntime Caused by: java.lang.ClassNotFoundException: Didn't find class “android.support.multidex.MultiDexApplication” java.lang.RuntimeException和java.lang.classNotFoundException - java.lang.RuntimeException and java.lang.classNotFoundException Unity C#和Layar SDK Java-AndroidJavaException - Unity C# and Layar SDK Java - AndroidJavaException Xamarin 使用 CallRedirectionService 抛出 Java.Lang.ClassNotFoundException - Xamarin throws Java.Lang.ClassNotFoundException using CallRedirectionService 单色接收器PACKAGE_REMOVED java.lang.ClassNotFoundException - monodroid receiver PACKAGE_REMOVED java.lang.ClassNotFoundException 尝试调用类构造函数时在Unity中获取AndroidJavaException - Getting AndroidJavaException in Unity when trying to call class constructor AndroidJavaException: java.lang.NoSuchMethodError: no non-static method with name='getStatusCode' signature='()I' - AndroidJavaException: java.lang.NoSuchMethodError: no non-static method with name='getStatusCode' signature='()I' xamarin 表单映射崩溃在路径上找不到类“com.google.android.gms.dynamic.zza”:DexPathList - xamarin forms maps crashes Didn't find class "com.google.android.gms.dynamic.zza" on path: DexPathList
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM