When the user installs an APK built with Unity, He/She could use '$adb install xxx.apk' to install this app to “/data/app” partition and the library packed in this APK will be moved to “/data/data/{package name}/lib/xxx.so”. We are attempting to pack an app into our system image. The APK will be placed in “/system/app”. To do so, we also need to pull out libraries from APK and put them into “/system/lib“ It seems Unity hard-codes the target library path to “/data/data/{package name}/lib/xxx.so” (as per installed apps). But for built-in app (not installed app), its library should be in “/system/lib/xxx.so” So what I'm asking is how to change the library path Ex : System.loadLibrary(“xxx”) but not System.loadLibrary(“/data/data/{package name}/lib/xxx.so”) Then system should automatically find the specific library from “/system/lib” or “/data/data/{package name}/lib” regardless of whether it is a built-in app or an installed app.
Thanks for the suggestion! Didnt think I could get away with that but decompiling the java was surprisingly easy =)
Hi, Made some progress. There are two missing libraries, libunity.so and libmono.so I started by removing the libs from /system/lib and running the app. Here is the error: IllegalArgumentException: Unable to find native library: mono Next, I pushed the libs back to /system/lib and tried again: IllegalArgumentException: Unable to find native library: unity So the UnityPlayer is able to find libmono but not libunity, even though they are both in the proper directory. Decompiling the class.dex contained in the APK revealed only this non-specific function call: A few other tidbits...this is the manifest.mf contained in the APK. It appears to contain references to the libs:
Based on the information given here http://java.sun.com/developer/Books/javaprogramming/JAR/basics/manifest.html the manifest.mf is part of the security system built around signing the apk...so that is a dead end. In UnityPlayer.java I will try changing the System.LoadLibrary(xxx.so) to System.Load(xxx.so)...hopefully then system will automatically find the specific library from “/system/lib” or “/data/data/{package name}/lib” Ex : System.load(“xxx”) but not System.loadLibrary(“/data/data/{package name}/lib/xxx.so”) I'm not sure how to rebuild the decompiled jar file back into a .class, then I must repack the APK? Suggestions?
Hi padworx, Since I have had a lot of people referring to this thread, I'm posting a reply even though you probably moved on by now. The unity player uses System.loadLibrary("libunity.so"), and not System.load("/<path>/libunity.so"). And if you put the libraries into /system/lib th e UnitPlayer will succeed loading both libs. However, the problem seems to be with the NativeActivity implementation. According to AOSP it always prepend the library path with ApplicationInfo.nativeLibraryDir. http://androidxref.com/4.2.2_r1/xref/frameworks/base/core/java/android/app/NativeActivity.java#172 I'm currently trying to figure out how this is supposed to be setup using the NativeActivity path, but if you are in a hurry you can try switching to the regular java activity - just move the MAIN intent to UnityPlayerActivity. This will give some additional input latency but depending on the game you have that may be fine.
Hey ppl! I re-bump this thread cause we're having the same issue and don't know what to do. Any walkaround? Thanks!
Is there an solution to this issue? It seems like it is simply impossible to install Unity APKs as system applications. I've tried pushing the libs (libmono and libunity) to system/lib but that doesn't work. Can it be done? - Raph -
I ended up placing the shared lib's in a certain directory (In my case, we used the StreamingAssets dir), and using the .net functions to set that specific directory as the current working directory before calling the DLLImport that requires shared libs. When doing this, the dll we loaded was able to look in the working directory for its dependents, and it worked from there. Updating is a bit of a pain, but if installing to the SDCARD you can workaround it with some simple scripting. if not installing to the SDCARD, have root (From foggy memory of a prototype project a couple months back, if you need more details yell and I can dig up the specifics.)
Seeing the exact same issue here. @bitter were you ever able to make progress on this? I've tried to add in a static function to manually load the libraries in the NativeActivity but so far have had no luck. http://forum.unity3d.com/threads/pr...find-native-library-main.321210/#post-2086902