-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
Milestone
Description
Hi, I'm using robolectric framework for unit testing my android application. Since some of my function highly depends on native method(.so file). The native library could be load successfully on devices but I got UnsatisfiedLinkError while running unit test. If I really want to test the functionality of the native method, what should I do?? I can build the native library into x86 format. But I don't know how to let the testing framework link it.
stanmots, GrahamBorland, dai0304, regisd, ysaber and 21 more
Metadata
Metadata
Assignees
Labels
Type
Projects
Relationships
Development
Select code repository
Activity
[-]How to test native method with robolectric [/-][+]Support libraries that package native libraries[/+]erd commentedon Jul 8, 2015
I was hoping that the Android Gradle plugin would unpack native libs into a directory similar to what it does for manifests, resources, etc, but it seems like this is not the case. In fact, it doesn't seem like the .so files are included in the build output. This might be considerably harder than I was thinking.
jaredsburrows commentedon Jul 8, 2015
@erd What happened? Why was this functionality removed in 2.x?
See http://stackoverflow.com/questions/10425591/robolectric-tanks-on-application-objects-that-load-jni-libraries-can-i-get-a-wo.
jaredsburrows commentedon Jul 8, 2015
@erd
Searching:
Commits:
First Commit:
Second Commit:
erd commentedon Jul 10, 2015
I'm not sure - I'll have to dig into the history.
StefMa commentedon Jul 17, 2015
I've search and find this and #1628 and #1171 (and more :))
So, currently we have no chance to test "things" (like Fragments and Activitys) which use native code?
marcinkunert commentedon Jul 17, 2015
I've tried to do this, also without using robolectric and I doubt this can be made. The reason is simple: the libraries package a .so object - typical for linux environment. There is now way to load and run it on windows without building the library from scratch to *.dll. For now NDK is not able to build a *.dll.
Even if run under linux - there may be many dependencies to the android OS inside a native library.
Eventually I've failed in my trials - we are now testing the native part using instrumental tests on device/emulator and all the other functionality with junits/robolectric.
krevelen commentedon Sep 7, 2015
We're also running into this, and are forced to create another app for (robolectric-based) instrumental tests that require the native code. It apparently was not supported originally (#782), then it was possible in v1.2 (http://stackoverflow.com/a/11378926/1418999), and now in v2.0 and v3.0 it isn't anymore (#1171, #1389, #1516, #1628). Anyone know the prognosis for this feature?
jcogilvie commentedon Sep 28, 2015
I'm running into this as well. I've got dependencies on libraries which include NDK dependencies on .so files, but I have no NDK binaries at the top level.
To @erd's first point about unpacking the native .so files, you can find them in the build/intermediates/exploded-aars directory under **/jni/*.so. I'm not sure if that's helpful for what you're trying to accomplish though.
28 remaining items