Call method from c++ plugin in thread


after Googling around for a while I thought maybe someone here knows an answer to my issue. I have a c++ lib compiled as .so-file for android. Calling these c++ methods from unity is no problem within the main thread and it’s all working. Due to performance issues I want to put the c++ calls in a seperate background worker.

Now if I create a background worker and start the calls I get an error message in log cat while running on an android device:

Unable to find 'myCustomLibName'
(Filename: PlatformDependent/AndroidPlayer/DVMCalls.cpp Line: 168)

This is my background worker test:

private static extern void libMethod();

void Start()
    BackgroundWorker bw = new BackgroundWorker();
    bw.DoWork += new DoWorkEventHandler(bw_DoWork);


private void bw_DoWork(object sender, DoWorkEventArgs e)

    libMethod(); //<-- c++ method call 

Would be great if anybody could help me with this issue.


  • I’m using Untiy Pro and Android Pro btw

  • changed ‘libName’ to ‘myCustomLibName’ to avoid confusion

You mention that it’s working from the main thread, however from all i know (and from the docs here: Unity - Manual: Create and use plug-ins in Android)

It is said that the attribute should declare the library WITHOUT the “lib” prefix.

e.g, you would have to define your extern method like this:

private static extern void libMethod();

Where is the filename that you place under Plugins/Android