-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Support libraries that package native libraries #1171
Comments
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. |
@erd What happened? Why was this functionality removed in 2.x? |
Searching:
Commits:
First Commit:
Second Commit:
|
I'm not sure - I'll have to dig into the history. |
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. |
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? |
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. |
Any updates on this? |
Is this support in plan? I am also looking out for the same thing. |
I'm also running into same issue, because of Parse |
Hitting this too with an application that uses OkHttpClient Full output:
|
Shouldn't the native code have it's own tests. If you want to test that your own code makes the correct calls into the native code and handles the results returned, why not do a wrapper around the code, and use something like Mockito to mock out the methods. If you are using dependency injection like dagger or roboguice, you can then inject the mock and verify that the results work. It sounds more like you guys are doing Integration tests instead of unit tests. Use an integration test framework like esspresso which runs in an emulator or on the device to test the integration of your native code with the android app code. |
I'm sure we all know how to write tests, and know what the difference However, robolectric has a lot of code that works at the Fragment or Personally, I'm coming at this from the approach of adding tests to legacy On Fri, Mar 11, 2016 at 1:44 PM, David Carver notifications@github.com
|
All DataManagers that use SnappyDB inside will be failed in test:
|
+1 |
Running into this issue as well with android-database-sqlcipher |
In Robolectric testing framework, use your so library : Support libraries that package native librariesSummary1. Disable load so in your app code. 2. Porting Dynamic Link Library.
# .o
cc -c -I/System/Library/Frameworks/JavaVM.framework/Headers *.cpp
# get xxx.dylib
g++ -dynamiclib -undefined suppress -flat_namespace *.o -o something.dylib
3. Load so library in your RobolectricApplication. End, run your test case, well done: DetailSample code: RobolectricSupportNativeLibs blog - http://rocko.xyz/2016/11/27/Android-Robolectric-加载运行本地-so-动态库/ |
Could someone provide a git repo or a pull request with a failing test for this? |
@zhengxiaopeng |
Do we have any updates on this @xian ? |
If you run your test on Windows, you need to load the dll version of your library. @Before
fun ini(){
Runtime.getRuntime().load("D:\\dev\\opencv\\opencv-4.0.1\\build\\java\\x64\\opencv_java401.dll")
} use |
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.
The text was updated successfully, but these errors were encountered: