Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to load DLL 'mediapipe_jni' on Android build #96

Closed
emreboyraz0 opened this issue Mar 20, 2021 · 15 comments
Closed

Unable to load DLL 'mediapipe_jni' on Android build #96

emreboyraz0 opened this issue Mar 20, 2021 · 15 comments
Labels
platform:android Issue that occurs when the target platform is Android type:build/install Cannot build/install the plugin

Comments

@emreboyraz0
Copy link

I am getting "Unable to load DLL 'mediapipe_jni' error in Android and there is no camera image.
Is this error known issue?
Can you tell how can i fix this?

DllNotFoundException: Unable to load DLL 'mediapipe_jni': The specified module could not be found. 03-20 14:12:51.801 14324 14340 E Unity : at Mediapipe.SafeNativeMethods.mp_api__ResetResourceManager (System.IntPtr resolverPtr, System.IntPtr handlerPtr) [0x00000] in <00000000000000000000000000000000>:0 03-20 14:12:51.801 14324 14340 E Unity : at Mediapipe.ResourceManager.Finalize () [0x00000] in <00000000000000000000000000000000>:0 03-20 14:12:51.801 14324 14340 E Unity : System.UnhandledExceptionEventHandler:Invoke(Object, UnhandledExceptionEventArgs) 03-20 14:12:51.801 14324 14340 E Unity : 03-20 14:12:51.801 14324 14340 E Unity : (Filename: currently not available on il2cpp Line: -1) 03-20 14:12:51.801 14324 14340 E Unity : 03-20 14:12:52.344 14324 14336 E Unity : NullReferenceException: Object reference not set to an instance of an object. 03-20 14:12:52.344 14324 14336 E Unity : at AssetBundleLoader.PrepareAsset (System.String name, System.String uniqueKey, System.Boolean overwrite) [0x00000] in <00000000000000000000000000000000>:0 03-20 14:12:52.344 14324 14336 E Unity : at DemoGraph.Initialize () [0x00000] in <00000000000000000000000000000000>:0 03-20 14:12:52.344 14324 14336 E Unity : at SceneDirector+<RunGraph>d__24.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 03-20 14:12:52.344 14324 14336 E Unity : at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00000] in <00000000000000000000000000000000>:0

@homuler
Copy link
Owner

homuler commented Mar 21, 2021

Will you tell me the steps to reproduce this issue?

And please see #73 (comment) .

@emreboyraz0
Copy link
Author

emreboyraz0 commented Mar 22, 2021

yesterday update solved the issue. Thanks
But in android build in SceneDirector.cs
`
#if UNITY_ANDROID && !UNITY_EDITOR // Should add !UNITY_EDITOR otherwise there is compiler error given
if (IsGpuEnabled()) {
PluginCallback callback = GetCurrentContext;

  var fp = Marshal.GetFunctionPointerForDelegate(callback);
  GL.IssuePluginEvent(fp, 1);
}

#endif
`

@mgarbade
Copy link
Contributor

For me the problem was that Unity compiled for arm v7 but the plugin expected arm v8 64bit.

fix was to configure arm64 in Unity Editor:
BuildSettings -> Player -> Other Settings -> TargetArchitectures -> ARM64

@homuler
Copy link
Owner

homuler commented Sep 24, 2021

You can also build for armv7 if you want.

python build.py build --android arm -vv

@mgarbade
Copy link
Contributor

mgarbade commented Oct 7, 2021

Actually I reencountered the above "Unable to load mediapipe_jni" error on specific android devices. While on my Samsung S6 and S7 devices the app works fine, it crashes on Motorola Z2

DllNotFoundException: Unable to load DLL 'mediapipe_jni': The specified module could not be found.
      at Mediapipe.SafeNativeMethods.mp__SetCustomGlobalPathResolver__P (Mediapipe.ResourceManager+PathResolver resolver) [0x00000] in <00000000000000000000000000000000>:0 
      at Mediapipe.ResourceManager..ctor () [0x00000] in <00000000000000000000000000000000>:0 
      at AssetBundleLoader.Start () [0x00000] in <00000000000000000000000000000000>:0 

@mgarbade
Copy link
Contributor

mgarbade commented Oct 7, 2021

I tried your recommendation of compiling for armv7, but it didn't help, but rather lead to different errors:

2021.10.07 12:07:34.714 23629 23674 Warn System.err 	at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20)
2021.10.07 12:07:34.716 23629 23674 Error org.aisc.ailib.impl.api.AILibImpl 2021-10-07 12:07:34.715 org.aisc.ailib.impl.tools.AndroidLogger#e:55
2021.10.07 12:07:34.716 23629 23674 Error org.aisc.ailib.impl.api.AILibImpl  Unhandled exception: EXCEPTION: DllNotFoundException: Unable to load DLL 'mediapipe_jni': The specified module could not be found.
2021.10.07 12:07:34.716 23629 23674 Error org.aisc.ailib.impl.api.AILibImpl Trace:
2021.10.07 12:07:34.716 23629 23674 Error org.aisc.ailib.impl.api.AILibImpl 
2021.10.07 12:07:34.716 23629 23674 Error org.aisc.ailib.impl.api.AILibImpl java.lang.RuntimeException: EXCEPTION: DllNotFoundException: Unable to load DLL 'mediapipe_jni': The specified module could not be found.
2021.10.07 12:07:34.716 23629 23674 Error org.aisc.ailib.impl.api.AILibImpl Trace:
2021.10.07 12:07:34.716 23629 23674 Error org.aisc.ailib.impl.api.AILibImpl 
2021.10.07 12:07:34.716 23629 23674 Error org.aisc.ailib.impl.api.AILibImpl 	at de.nukklear.ailibbridge.impl.BaseImplementation.logError(BaseImplementation.java:177)
2021.10.07 12:07:34.716 23629 23674 Error org.aisc.ailib.impl.api.AILibImpl 	at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
2021.10.07 12:07:34.716 23629 23674 Error org.aisc.ailib.impl.api.AILibImpl 	at com.unity3d.player.UnityPlayer.access$300(Unknown Source:0)
2021.10.07 12:07:34.716 23629 23674 Error org.aisc.ailib.impl.api.AILibImpl 	at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:95)
2021.10.07 12:07:34.716 23629 23674 Error org.aisc.ailib.impl.api.AILibImpl 	at android.os.Handler.dispatchMessage(Handler.java:101)
2021.10.07 12:07:34.716 23629 23674 Error org.aisc.ailib.impl.api.AILibImpl 	at android.os.Looper.loop(Looper.java:164)
2021.10.07 12:07:34.716 23629 23674 Error org.aisc.ailib.impl.api.AILibImpl 	at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20)
2021.10.07 12:07:34.718 23629 23674 Error Unity DllNotFoundException: Unable to load DLL 'mediapipe_jni': The specified module could not be found.

when compiling with your master from Aug. 16th 2021. and

@mgarbade
Copy link
Contributor

mgarbade commented Oct 7, 2021

Correction: With the new master it works also on Motorola Z2 + arm64

@homuler homuler added platform:android Issue that occurs when the target platform is Android type:build/install Cannot build/install the plugin labels Jan 10, 2022
@portari
Copy link

portari commented Jun 16, 2022

@homuler I need help to understand something very simple, even if it seems obvious. I'm studying the MediaPipeUnityPlugin but I don't think I understand something correctly. I compiled on Windows10 for desktop CPU - and it worked just fine on Unity. I converted the Unity application to Android and generated the apk. When I install it on Android it doesn't work. So that I can run it on Android do I need to build it for Android or am I making a mistake in the Unity Player configuration? Sorry to ask in this thread, but I needed to get it working on Android and I'm new to both Unity and MediaPipe. Thanks in advance. [email protected]

@homuler
Copy link
Owner

homuler commented Jun 16, 2022

@portari See #492 (comment) and https://github.com/homuler/MediaPipeUnityPlugin/wiki/Installation-Guide#dllnotfoundexception.

In your case, you should have built mediapipe_c.dll, but it doesn't work on Android.
To run the plugin on Android devices, you need to build mediapipe_android.aar.

@portari
Copy link

portari commented Jun 17, 2022

@portari See #492 (comment) and https://github.com/homuler/MediaPipeUnityPlugin/wiki/Installation-Guide#dllnotfoundexception.

In your case, you should have built mediapipe_c.dll, but it doesn't work on Android. To run the plugin on Android devices, you need to build mediapipe_android.aar.

Muito obrigado mesmo kkkk Thank you, so much!

After fighting a bit with the versions of nuget on Linux, I managed to generate the version for Android, and joining with the dll generated on Windows previously, the plugin is working very well. I couldn't have done it without your help and your work. congratulations indeed.
Frutal, Minas Gerais, Brasil, 17/06/2022

IMG-20220617-WA0008

@portari
Copy link

portari commented Jun 17, 2022

@portari See #492 (comment) and https://github.com/homuler/MediaPipeUnityPlugin/wiki/Installation-Guide#dllnotfoundexception.

In your case, you should have built mediapipe_c.dll, but it doesn't work on Android. To run the plugin on Android devices, you need to build mediapipe_android.aar.

@homuler there's only one but still: I have a Samsung M62, which has a salad of processors: 4x 1.95 GHz Cortex-A55 + 2x 2.4 GHz Cortex-A75 + 2x 2.73 GHz M4 and Mali-G76 MP12 GPU, and when I opened the app, it open the camera and then close the app. I tested it on a Samsung S21 with 1x 2.9 GHz Cortex-X1 + 3x 2.8 GHz Cortex-A78 + 4x 2.2 GHz Cortex-A55 processors and Mali-G78 MP14 GPU and it worked fine. Now I'm looking if there's something to tweak to work on both, or mine at least. If you know anything that helps, I'd appreciate it. thanks for the attention.

@homuler
Copy link
Owner

homuler commented Jun 18, 2022

@portari Did you read https://github.com/homuler/MediaPipeUnityPlugin/wiki/Installation-Guide#dllnotfoundexception?

  1. Native libraries are incompatible with your device
    ii. If it occurs on your Android device, maybe

First, you should check the error log (e.g. adb -s [device_id] logcat Unity:V native:V tflite:V CRASH:E AndroidRuntime:E "*:S") and identify the cause.
See also #536 (comment),

@homuler
Copy link
Owner

homuler commented Jun 19, 2022

@portari If you need help, please build with Development Build enabled and create a new issue.

@portari
Copy link

portari commented Jun 19, 2022

@portari If you need help, please build with Development Build enabled and create a new issue.

@homuler I am so sorry for inconvenient. Thanks for the help. I'll do this.

@crawfis
Copy link

crawfis commented Feb 21, 2024

Should a Windows build be referencing mediapipe_jni? Unity is really messed up on its caching. I have upgraded to 2023.3 beta hoping for a previous fix where Android builds would not work due to some cache in a prior Windows Build. Now it is the opposite and I need to find what files to delete to get a Windows build to work (or go back to the Cloud build). But curious if this is the problem based on mediapipe_jni.dll missing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform:android Issue that occurs when the target platform is Android type:build/install Cannot build/install the plugin
Projects
None yet
Development

No branches or pull requests

5 participants