[Firebase-Unity3D] Android IL2CPP: libApp.so, error: Cannot load library

988 views
Skip to first unread message

pikachu

unread,
Nov 14, 2016, 10:10:02 AM11/14/16
to Firebase Google Group
Hello,

I checked out the messaging sample app (https://github.com/firebase/quickstart-unity/tree/master/messaging/testapp), and try to build for Android platform. With the scripting backend option is Mono2x, everything is working ok on device, but with option IL2CPP, the Android logcat shows following errors on Firebase initialize method:

11-14 10:31:17.233: E/Unity(5088): Couldn't open /data/app-lib/com.firebase.testfcm-1/libApp.so, error: Cannot load library:
11-14 10:31:17.233: E/Unity(5088): System.Threading.Tasks.<Post>c__AnonStorey0:<>m__0(Object)
11-14 10:31:17.233: E/Unity(5088): [ line 125]
11-14 10:31:17.233: E/Unity(5088): (Filename:  Line: 125)
11-14 10:31:17.253: I/Unity(5088): DllNotFoundException: Unable to load DLL 'App': The specified module could not be found.
11-14 10:31:17.253: I/Unity(5088):   at Firebase.AppUtilPINVOKE+SWIGExceptionHelper.SWIGRegisterExceptionCallbacks_AppUtil (Firebase.ExceptionDelegate applicationDelegate, Firebase.ExceptionDelegate arithmeticDelegate, Firebase.ExceptionDelegate divideByZeroDelegate, Firebase.ExceptionDelegate indexOutOfRangeDelegate, Firebase.ExceptionDelegate invalidCastDelegate, Firebase.ExceptionDelegate invalidOperationDelegate, Firebase.ExceptionDelegate ioDelegate, Firebase.ExceptionDelegate nullReferenceDelegate, Firebase.ExceptionDelegate outOfMemoryDelegate, Firebase.ExceptionDelegate overflowDelegate, Firebase.ExceptionDelegate systemExceptionDelegate) [0x00000] in <filename unknown>:0
11-14 10:31:17.253: I/Unity(5088):   at Firebase.AppUtilPINVOKE+SWIGExceptionHelper..cctor () [0x00000] in <filename unknown>:0
11-14 10:31:17.253: I/Unity(5088):   at System.Collections.Generic.Dictionary`2+Transform`1[TKey,TValue,TRet].EndInvoke (IAsyncResult result) [0x00000] in <filename unknown>:0
11-14 10:31:17.253: I/Unity(5088):   at System.Threading.Tasks.TaskScheduler+<

Has anyone have same problems?

Thank you.

c.santa...@brbent.com

unread,
Nov 15, 2016, 5:50:13 PM11/15/16
to Firebase Google Group
Same issue here. I have been trying to integrate Firebase into a project and finally figured out it was due to IL2CPP. Turned it to Mono2 and it worked immediately.

Anybody know what can be done to get this to work with IL2CPP?

Stewart Miles

unread,
Nov 15, 2016, 5:55:29 PM11/15/16
to fireba...@googlegroups.com
Hi folks,

We don't have a solution for this yet, it's in our queue.  For the moment, your workaround of disabling IL2CPP on Android is the way to go.

Cheers,
Stewart

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/63819467-4141-4d0d-a0b1-f159ec1a2351%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

c.santa...@brbent.com

unread,
Nov 15, 2016, 7:08:51 PM11/15/16
to Firebase Google Group
Our project will require IL2CPP for its release build. 

Do you believe we can rely on IL2CPP support for Firebase Unity being worked out within a couple months, or should we look to another messaging solution for now?

Thanks for the quick reply!
-Chance


On Tuesday, November 15, 2016 at 2:55:29 PM UTC-8, Stewart Miles wrote:
Hi folks,

We don't have a solution for this yet, it's in our queue.  For the moment, your workaround of disabling IL2CPP on Android is the way to go.

Cheers,
Stewart
On Tue, Nov 15, 2016 at 2:48 PM, <c.santa...@brbent.com> wrote:
Same issue here. I have been trying to integrate Firebase into a project and finally figured out it was due to IL2CPP. Turned it to Mono2 and it worked immediately.

Anybody know what can be done to get this to work with IL2CPP?

On Monday, November 14, 2016 at 7:10:02 AM UTC-8, pikachu wrote:
Hello,

I checked out the messaging sample app (https://github.com/firebase/quickstart-unity/tree/master/messaging/testapp), and try to build for Android platform. With the scripting backend option is Mono2x, everything is working ok on device, but with option IL2CPP, the Android logcat shows following errors on Firebase initialize method:

11-14 10:31:17.233: E/Unity(5088): Couldn't open /data/app-lib/com.firebase.testfcm-1/libApp.so, error: Cannot load library:
11-14 10:31:17.233: E/Unity(5088): System.Threading.Tasks.<Post>c__AnonStorey0:<>m__0(Object)
11-14 10:31:17.233: E/Unity(5088): [ line 125]
11-14 10:31:17.233: E/Unity(5088): (Filename:  Line: 125)
11-14 10:31:17.253: I/Unity(5088): DllNotFoundException: Unable to load DLL 'App': The specified module could not be found.
11-14 10:31:17.253: I/Unity(5088):   at Firebase.AppUtilPINVOKE+SWIGExceptionHelper.SWIGRegisterExceptionCallbacks_AppUtil (Firebase.ExceptionDelegate applicationDelegate, Firebase.ExceptionDelegate arithmeticDelegate, Firebase.ExceptionDelegate divideByZeroDelegate, Firebase.ExceptionDelegate indexOutOfRangeDelegate, Firebase.ExceptionDelegate invalidCastDelegate, Firebase.ExceptionDelegate invalidOperationDelegate, Firebase.ExceptionDelegate ioDelegate, Firebase.ExceptionDelegate nullReferenceDelegate, Firebase.ExceptionDelegate outOfMemoryDelegate, Firebase.ExceptionDelegate overflowDelegate, Firebase.ExceptionDelegate systemExceptionDelegate) [0x00000] in <filename unknown>:0
11-14 10:31:17.253: I/Unity(5088):   at Firebase.AppUtilPINVOKE+SWIGExceptionHelper..cctor () [0x00000] in <filename unknown>:0
11-14 10:31:17.253: I/Unity(5088):   at System.Collections.Generic.Dictionary`2+Transform`1[TKey,TValue,TRet].EndInvoke (IAsyncResult result) [0x00000] in <filename unknown>:0
11-14 10:31:17.253: I/Unity(5088):   at System.Threading.Tasks.TaskScheduler+<

Has anyone have same problems?

Thank you.

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

Stewart Miles

unread,
Nov 15, 2016, 7:16:11 PM11/15/16
to fireba...@googlegroups.com
I'm hoping we'll have a solution for you within a couple of months yet.

BTW Why do you need IL2CPP for the release version of your game on Android?  We shouldn't have platform level requirements for this, is it primarily a performance issue?

Cheers,
Stewart

To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

Nicklas Ruiterman

unread,
Nov 15, 2016, 10:30:03 PM11/15/16
to Firebase Google Group
It's my understanding that IL2CPP is the goal for all Unity build targets
without it my game would be unplayable on low end phones

Stewart Miles

unread,
Nov 16, 2016, 12:29:07 PM11/16/16
to fireba...@googlegroups.com
IL2CPP will help with CPU performance which - unless you're running a load of physics or CPU based animation - is probably not going to be your bottleneck.  I recommend profiling testing first before assuming that IL2CPP will help you :)

To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

c.santa...@brbent.com

unread,
Nov 16, 2016, 5:45:09 PM11/16/16
to Firebase Google Group
Physics and Animation are definitely common features of many Unity games, so I'd say that is a more common bottleneck than you may be anticipating. Additionally, IL2CPP is used to decrease the size of the deployed package and to provide some measure of decompilation protection / code obfuscation. For our project, it's a little bit of all of these factors that have made it a requirement.

Good news though, I actually found a way to get it to work with IL2CPP. 

It seems that Swig has a problem with IL2CPP if you don't append the MonoPInvokeCallback attribute to any static methods that are used as callbacks. After I cracked open the dlls, added the attributes, and recompiled them, it worked like a charm.

I've attached one of the two ...UtilPINVOKE.cs files that needed edits for your reference. They're probably a bit different than the copies in your source since C#/IL conversion isn't 100% reversible.

Cheers!
-Chance
AppUtilPINVOKE.cs

Stewart Miles

unread,
Nov 16, 2016, 6:10:10 PM11/16/16
to fireba...@googlegroups.com
I don't know how much physics, animation the typical match 3 game has :)  Code size could actually be worse as IL is platform independent and TBH I *think* it's JIT'd on Android anyway.  That said...

Thanks for the patch Chance, it turns out we already have a load of code to apply these fix ups and we currently have them only enabled for iOS :/  I'll enable the patch for other platforms and give it a try.  Will post to this thread with the results.

Cheers,
Stewart

To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

deepixel

unread,
Nov 17, 2016, 8:02:00 AM11/17/16
to Firebase Google Group
While waiting for the official patch from Google Firebase, who need to release the game at this time with IL2CPP can try this plugin (Android & iOS both):

https://www.assetstore.unity3d.com/en/#!/content/72683

I've tried it with Android IL2CPP and have no problem.

Chance Santana-Wees

unread,
Nov 17, 2016, 8:02:09 AM11/17/16
to fireba...@googlegroups.com
True, the typical use case for the Unity/Firebase user probably won't be too CPU intensive... but there are a few of us out there doing things in Unity that are a bit higher performance ;)

The IL2CPP runtime does run JIT for GC and whatnot, but all of the user defined scripts are compiled AOT into native libraries.

Java running in the Dalvik VM directly has somewhat comparable performance to native code, but when you throw the fact that Unity is running Scripts in Mono and running Mono in Dalvik the script performance tends to get pretty bad. IL2CPP cuts out mono, which Nets a surprisingly meaningful performance boost despite Dalvik still being there as a performance bottleneck on memory allocation and whatnot.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Firebase Google Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/firebase-talk/FYOrunc5rZ4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

Stewart Miles

unread,
Nov 17, 2016, 11:41:12 AM11/17/16
to fireba...@googlegroups.com
BTW We applied your suggested patch and it looks like it's working just need to validate with all services before we publish.

w.r.t perf, the rough way it goes is this..

Dalvik (whatever JVM) runs as a native process, the code running under the process is JIT'd to machine code which has ok performance at the potential expense of portability unless you're using Java-->Obj-C etc.

Mono is running as a native thread (i.e not under the JVM, though the JVM will exist in the same process).  IL (generated from your C#) runs in Mono which will also JIT to machine code generating pretty good performance.

When you use IL2CPP you'll end up with C/C++ that's compiled directly to machine code reducing startup times (due to JIT) and potentially resulting in slightly more perf gains when compared to JIT due to heaps of time engineers have spent optimizing GCC, Clang etc.  Like I said before, this does result in a larger package if you're targeting multiple architectures as the compilation is ahead of time so you need to ship a separate binary for each arch.

IL2CPP is not a panacea for perf problems it's merely a tool that could help squeeze some additional performance gains out of your app, but really you need to profile and see where your bottlenecks are.

Cheers,
Stewart

On Wed, Nov 16, 2016 at 4:12 PM, Chance Santana-Wees <c.santa...@brbent.com> wrote:
True, the typical use case for the Unity/Firebase user probably won't be too CPU intensive... but there are a few of us out there doing things in Unity that are a bit higher performance ;)

The IL2CPP runtime does run JIT for GC and whatnot, but all of the user defined scripts are compiled AOT into native libraries.

Java running in the Dalvik VM directly has somewhat comparable performance to native code, but when you throw the fact that Unity is running Scripts in Mono and running Mono in Dalvik the script performance tends to get pretty bad. IL2CPP cuts out mono, which Nets a surprisingly meaningful performance boost despite Dalvik still being there as a performance bottleneck on memory allocation and whatnot.

To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Firebase Google Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/firebase-talk/FYOrunc5rZ4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to firebase-talk+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

Nicklas Ruiterman

unread,
Nov 17, 2016, 12:54:41 PM11/17/16
to Firebase Google Group
Thank you for posting your findings here Chance


Thanks Stewart, it's always good advice to profile on a case by case basis


very interesting to google all these technical terms and fill in a picture of what's being said :)


On Friday, November 18, 2016 at 5:41:12 AM UTC+13, Stewart Miles wrote:
BTW We applied your suggested patch and it looks like it's working just need to validate with all services before we publish.

w.r.t perf, the rough way it goes is this..

Dalvik (whatever JVM) runs as a native process, the code running under the process is JIT'd to machine code which has ok performance at the potential expense of portability unless you're using Java-->Obj-C etc.

Mono is running as a native thread (i.e not under the JVM, though the JVM will exist in the same process).  IL (generated from your C#) runs in Mono which will also JIT to machine code generating pretty good performance.

When you use IL2CPP you'll end up with C/C++ that's compiled directly to machine code reducing startup times (due to JIT) and potentially resulting in slightly more perf gains when compared to JIT due to heaps of time engineers have spent optimizing GCC, Clang etc.  Like I said before, this does result in a larger package if you're targeting multiple architectures as the compilation is ahead of time so you need to ship a separate binary for each arch.

IL2CPP is not a panacea for perf problems it's merely a tool that could help squeeze some additional performance gains out of your app, but really you need to profile and see where your bottlenecks are.

Cheers,
Stewart
On Wed, Nov 16, 2016 at 4:12 PM, Chance Santana-Wees <c.santa...@brbent.com> wrote:
True, the typical use case for the Unity/Firebase user probably won't be too CPU intensive... but there are a few of us out there doing things in Unity that are a bit higher performance ;)

The IL2CPP runtime does run JIT for GC and whatnot, but all of the user defined scripts are compiled AOT into native libraries.

Java running in the Dalvik VM directly has somewhat comparable performance to native code, but when you throw the fact that Unity is running Scripts in Mono and running Mono in Dalvik the script performance tends to get pretty bad. IL2CPP cuts out mono, which Nets a surprisingly meaningful performance boost despite Dalvik still being there as a performance bottleneck on memory allocation and whatnot.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Firebase Google Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/firebase-talk/FYOrunc5rZ4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.

Chance Santana-Wees

unread,
Nov 17, 2016, 3:45:59 PM11/17/16
to fireba...@googlegroups.com
Interesting, I did not know Mono was running on a native thread.

I know that in my personal experience IL2CPP does improve script performance by quite a bit on both iOS and Android. So the fact that Mono isn't running on Dalvik just makes me more curious as to what the big performance differences between managed code running in Mono and Dalvik on Android actually are...

Unfortunately it seems there is a lot of misinformation on this in the Unity community!

On Thu, Nov 17, 2016 at 8:41 AM 'Stewart Miles' via Firebase Google Group <fireba...@googlegroups.com> wrote:
BTW We applied your suggested patch and it looks like it's working just need to validate with all services before we publish.

w.r.t perf, the rough way it goes is this..

Dalvik (whatever JVM) runs as a native process, the code running under the process is JIT'd to machine code which has ok performance at the potential expense of portability unless you're using Java-->Obj-C etc.

Mono is running as a native thread (i.e not under the JVM, though the JVM will exist in the same process).  IL (generated from your C#) runs in Mono which will also JIT to machine code generating pretty good performance.

When you use IL2CPP you'll end up with C/C++ that's compiled directly to machine code reducing startup times (due to JIT) and potentially resulting in slightly more perf gains when compared to JIT due to heaps of time engineers have spent optimizing GCC, Clang etc.  Like I said before, this does result in a larger package if you're targeting multiple architectures as the compilation is ahead of time so you need to ship a separate binary for each arch.

IL2CPP is not a panacea for perf problems it's merely a tool that could help squeeze some additional performance gains out of your app, but really you need to profile and see where your bottlenecks are.

Cheers,
Stewart

On Wed, Nov 16, 2016 at 4:12 PM, Chance Santana-Wees <c.santa...@brbent.com> wrote:
True, the typical use case for the Unity/Firebase user probably won't be too CPU intensive... but there are a few of us out there doing things in Unity that are a bit higher performance ;)

The IL2CPP runtime does run JIT for GC and whatnot, but all of the user defined scripts are compiled AOT into native libraries.

Java running in the Dalvik VM directly has somewhat comparable performance to native code, but when you throw the fact that Unity is running Scripts in Mono and running Mono in Dalvik the script performance tends to get pretty bad. IL2CPP cuts out mono, which Nets a surprisingly meaningful performance boost despite Dalvik still being there as a performance bottleneck on memory allocation and whatnot.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Firebase Google Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/firebase-talk/FYOrunc5rZ4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Firebase Google Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/firebase-talk/FYOrunc5rZ4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

Stewart Miles

unread,
Nov 18, 2016, 7:19:33 PM11/18/16
to Firebase Google Group
Hi everyone,

We've fixed this issue in the 1.0.1 release:

You can download the latest release from:

Cheers,
Stewart
Reply all
Reply to author
Forward
0 new messages