Skip to content
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

Open
joseph8282 opened this issue Jun 26, 2014 · 22 comments
Open

Support libraries that package native libraries #1171

joseph8282 opened this issue Jun 26, 2014 · 22 comments

Comments

@joseph8282
Copy link

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.

@erd erd changed the title How to test native method with robolectric Support libraries that package native libraries Apr 24, 2015
@erd
Copy link
Contributor

erd commented 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
Copy link
Contributor

@jaredsburrows
Copy link
Contributor

@erd

Searching:

$ git log -S addClassOrPackageToInstrument

Commits:

$ git log -S addClassOrPackageToInstrument
commit 56215a065f0b61b67bb7bb21f21b305da9a66c90
Author: Christian Williams & Dimitris Couchell <github+xian+dimitris@squareup.com>
Date:   Tue Nov 13 16:10:04 2012 -0800

    Extract Setup class for making decisions about instrumentation-time and runtime class handling.

commit f567a9e68c435fa0a98191c8ccda08add2f37566
Author: Rick Kawala & Ryan Richard <pair+rick+rrichard@pivotallabs.com>
Date:   Tue Oct 18 15:21:11 2011 -0700

    - allow shadowing of classes which have a private default constructor
    - allow subclasses of RobolectricTestRunner to provide a list of additional classes which should be shadowed

First Commit:

https://github.com/robolectric/robolectric/commit/56215a065f0b61b67bb7bb21f21b305da9a66c90

Second Commit:

https://github.com/robolectric/robolectric/commit/f567a9e68c435fa0a98191c8ccda08add2f37566

@erd
Copy link
Contributor

erd commented Jul 10, 2015

I'm not sure - I'll have to dig into the history.

@StefMa
Copy link

StefMa commented 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
Copy link

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
Copy link

krevelen commented 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
Copy link

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.

@bmschwartz
Copy link

Any updates on this?

@hiteshmehata
Copy link

Is this support in plan? I am also looking out for the same thing.

@ghost
Copy link

ghost commented Jan 13, 2016

I'm also running into same issue, because of Parse java.lang.UnsatisfiedLinkError: no javacrypto in java.library.path.

@dazza5000
Copy link

Hitting this too with an application that uses OkHttpClient

Full output:

/usr/lib/jvm/java-8-oracle/bin/java -ea -noverify -Didea.launcher.port=7534 -Didea.launcher.bin.path=/home/daz/Downloads/android-studio/bin -Didea.junit.sm_runner -Dfile.encoding=UTF-8 -classpath "/home/daz/Downloads/android-studio/lib/idea_rt.jar:/home/daz/Downloads/android-studio/plugins/junit/lib/junit-rt.jar:/media/development/android-sdk/adt-bundle-linux-x86_64-20131030/sdk/platforms/android-23/data/res:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/classes/test/drunk_mode/debug:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/classes/drunk_mode/debug:/home/daz/.gradle/caches/modules-2/files-2.1/com.jakewharton/butterknife/7.0.1/d5d13ea991eab0252e3710e5df3d6a9d4b21d461/butterknife-7.0.1.jar:/home/daz/.gradle/caches/modules-2/files-2.1/com.google.code.gson/gson/2.3.1/ecb6e1f8e4b0e84c4b886c2f14a1500caf309757/gson-2.3.1.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.google.android.gms/play-services-location/8.4.0/jars/classes.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.google.android.gms/play-services-location/8.4.0/res:/home/daz/.gradle/caches/modules-2/files-2.1/com.squareup.okio/okio/1.6.0/98476622f10715998eacf9240d6b479f12c66143/okio-1.6.0.jar:/home/daz/.gradle/caches/modules-2/files-2.1/org.assertj/assertj-core/1.7.0/c0451c7fce61d14f9f0fa84bb2760e548221e471/assertj-core-1.7.0.jar:/home/daz/.gradle/caches/modules-2/files-2.1/com.squareup.okhttp/okhttp/2.5.0/4de2b4ed3445c37ec1720a7d214712e845a24636/okhttp-2.5.0.jar:/home/daz/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm-commons/5.0.1/7b7147a390a93a14d2edfdcf3f7b0e87a0939c3e/asm-commons-5.0.1.jar:/home/daz/.gradle/caches/modules-2/files-2.1/com.facebook.stetho/stetho/1.2.0/1d6cdb8ce8185b8b23213fad48a83987fb6d2d67/stetho-1.2.0.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.google.android.gms/play-services-base/8.4.0/jars/classes.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.google.android.gms/play-services-base/8.4.0/res:/home/daz/.gradle/caches/modules-2/files-2.1/commons-cli/commons-cli/1.2/2bf96b7aa8b611c177d329452af1dc933e14501c/commons-cli-1.2.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.digits.sdk.android/digits/1.9.2/res:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.digits.sdk.android/digits/1.9.2/jars/classes.jar:/home/daz/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm/5.0.1/2fd56467a018aafe6ec6a73ccba520be4a7e1565/asm-5.0.1.jar:/home/daz/.gradle/caches/modules-2/files-2.1/org.robolectric/shadows-multidex/3.0/234b6a3024fe842492c85866295016f6dce8cfa/shadows-multidex-3.0.jar:/home/daz/.gradle/caches/modules-2/files-2.1/org.robolectric/shadows-core/3.0/9dfa881bfd1796afa28204ef1a5ed7e3de992612/shadows-core-3.0.jar:/home/daz/.gradle/caches/modules-2/files-2.1/com.parse/parse-android/1.11.0/6592129dec2caa8791d322c7e4b6b7a30e8eadae/parse-android-1.11.0.jar:/home/daz/.gradle/caches/modules-2/files-2.1/com.parse.bolts/bolts-tasks/1.3.0/8a62fd16fcc1c06f284fc98e6cbded2a5af1dd4c/bolts-tasks-1.3.0.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.1.1/res:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.1.1/jars/classes.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.google.maps.android/android-maps-utils/0.3.4/jars/classes.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.google.maps.android/android-maps-utils/0.3.4/res:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/libs/twrobserver-sdk.jar:/media/development/android-sdk/adt-bundle-linux-x86_64-20131030/sdk/extras/android/m2repository/com/android/support/support-annotations/23.1.1/support-annotations-23.1.1.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/dialoghelperlibrary/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.1.1/jars/classes.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/dialoghelperlibrary/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.1.1/res:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/libs/Parse-1.11.0/ParseFacebookUtilsV4-1.10.3.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/libs/Flurry Analytics/FlurryAnalytics-6.2.0.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/libs/Parse-1.11.0/ParseCrashReporting-1.9.4.jar:/home/daz/.gradle/caches/modules-2/files-2.1/com.ibm.icu/icu4j/53.1/786d9055d4ca8c1aab4a7d4ac8283f973fd7e41f/icu4j-53.1.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.crashlytics.sdk.android/beta/1.1.4/jars/classes.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.crashlytics.sdk.android/beta/1.1.4/res:/home/daz/.gradle/caches/modules-2/files-2.1/org.robolectric/robolectric-resources/3.0/1ab609054aab67cd13a434567467f4b4774f2465/robolectric-resources-3.0.jar:/home/daz/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm-tree/5.0.1/1b1e6e9d869acd704056d0a4223071a511c619e6/asm-tree-5.0.1.jar:/home/daz/.gradle/caches/modules-2/files-2.1/com.almworks.sqlite4java/sqlite4java/0.282/745a7e2f35fdbe6336922e0d492c979dbbfa74fb/sqlite4java-0.282.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.android.support/support-v13/23.1.1/jars/libs/internal_impl-23.1.1.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.android.support/support-v13/23.1.1/res:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.android.support/support-v13/23.1.1/jars/classes.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.twitter.sdk.android/tweet-composer/1.0.2/jars/classes.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.twitter.sdk.android/tweet-composer/1.0.2/res:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.twitter.sdk.android/twitter-core/1.6.2/jars/classes.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.twitter.sdk.android/twitter-core/1.6.2/res:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.crashlytics.sdk.android/answers/1.3.6/res:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.crashlytics.sdk.android/answers/1.3.6/jars/classes.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/libs/Parse-1.11.0/ParseInterceptors-0.0.1.jar:/home/daz/.gradle/caches/modules-2/files-2.1/org.robolectric/robolectric/3.0/f888cea3bc1a24110e315eb9827ab593610ea62f/robolectric-3.0.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.twitter.sdk.android/twitter/1.11.0/jars/classes.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.twitter.sdk.android/twitter/1.11.0/res:/home/daz/.gradle/caches/modules-2/files-2.1/org.apache.maven/maven-ant-tasks/2.1.3/b09be554228d66d208e5fef5266844aacf443abc/maven-ant-tasks-2.1.3.jar:/home/daz/.gradle/caches/modules-2/files-2.1/org.apache.ant/ant/1.8.0/7b456ca6b93900f96e58cc8371f03d90a9c1c8d1/ant-1.8.0.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/libs/Parse-1.11.0/ParseTwitterUtils-1.10.3.jar:/home/daz/.gradle/caches/modules-2/files-2.1/com.squareup.picasso/picasso/2.5.2/7446d06ec8d4f7ffcc53f1da37c95f200dcb9387/picasso-2.5.2.jar:/home/daz/.gradle/caches/modules-2/files-2.1/com.google.android.apps.common.testing.accessibility.framework/accessibility-test-framework/1.0/28162aae36f8ba5903adadfb570313e1f1be852e/accessibility-test-framework-1.0.jar:/home/daz/.gradle/caches/modules-2/files-2.1/org.apache.ant/ant-launcher/1.8.0/8b53ba16fa62fb1034da8f1de200ddc407c8381/ant-launcher-1.8.0.jar:/home/daz/.gradle/caches/modules-2/files-2.1/com.squareup.retrofit/retrofit/1.9.0/a681c044244d9fc375198588297a39ba78028423/retrofit-1.9.0.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.google.android.gms/play-services-maps/8.4.0/jars/classes.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.google.android.gms/play-services-maps/8.4.0/res:/home/daz/.gradle/caches/modules-2/files-2.1/org.jbundle.util.osgi.wrapped/org.jbundle.util.osgi.wrapped.org.apache.http.client/4.1.2/98c86e42679fe7ac066f6c242e0d14f0bce0bb7c/org.jbundle.util.osgi.wrapped.org.apache.http.client-4.1.2.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.twitter.sdk.android/tweet-ui/1.8.0/jars/classes.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.twitter.sdk.android/tweet-ui/1.8.0/res:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/dialoghelperlibrary/build/intermediates/exploded-aar/com.android.support/support-v4/23.1.1/jars/libs/internal_impl-23.1.1.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/dialoghelperlibrary/build/intermediates/exploded-aar/com.android.support/support-v4/23.1.1/jars/classes.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/dialoghelperlibrary/build/intermediates/exploded-aar/com.android.support/support-v4/23.1.1/res:/home/daz/.gradle/caches/modules-2/files-2.1/org.mockito/mockito-all/1.10.19/539df70269cc254a58cccc5d8e43286b4a73bf30/mockito-all-1.10.19.jar:/home/daz/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm-util/5.0.1/7c8caddfbd0b2d7b844f8fcc75175b9cb9cf4724/asm-util-5.0.1.jar:/home/daz/.gradle/caches/modules-2/files-2.1/org.bouncycastle/bcprov-jdk16/1.46/ce091790943599535cbb4de8ede84535b0c1260c/bcprov-jdk16-1.46.jar:/home/daz/.gradle/caches/modules-2/files-2.1/com.parse.bolts/bolts-android/1.3.0/27cabf3558be23a89f054334dd92512645ad34d9/bolts-android-1.3.0.jar:/home/daz/.gradle/caches/modules-2/files-2.1/com.google.code.findbugs/jsr305/2.0.1/516c03b21d50a644d538de0f0369c620989cd8f0/jsr305-2.0.1.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/io.fabric.sdk.android/fabric/1.3.10/jars/classes.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/io.fabric.sdk.android/fabric/1.3.10/res:/home/daz/.gradle/caches/modules-2/files-2.1/com.squareup.okhttp/okhttp-urlconnection/2.5.0/d737653459be272e881d51024274fa4785225641/okhttp-urlconnection-2.5.0.jar:/home/daz/.gradle/caches/modules-2/files-2.1/com.cocoahero.android/geojson/1.0.1/5ac9c72666b11d5817e8c3c1145e0b020725e7de/geojson-1.0.1.jar:/home/daz/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/19.0/6ce200f6b23222af3d8abb6b6459e6c44f4bb0e9/guava-19.0.jar:/home/daz/.gradle/caches/modules-2/files-2.1/de.greenrobot/eventbus/2.4.0/ddd166d01b3158d1c00576d29f7ed15c030df719/eventbus-2.4.0.jar:/home/daz/.gradle/caches/modules-2/files-2.1/com.facebook.stetho/stetho-okhttp/1.1.1/1732524bc9a7c660032c73133ce27749a64ba456/stetho-okhttp-1.1.1.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.crashlytics.sdk.android/crashlytics/2.5.5/res:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.crashlytics.sdk.android/crashlytics/2.5.5/jars/classes.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.android.support/cardview-v7/23.1.1/jars/classes.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.android.support/cardview-v7/23.1.1/res:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.crashlytics.sdk.android/crashlytics-core/2.3.8/jars/classes.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.crashlytics.sdk.android/crashlytics-core/2.3.8/res:/home/daz/.gradle/caches/modules-2/files-2.1/org.robolectric/robolectric-annotations/3.0/2a6cfc072d7680694c1ff893c5dc8fec33163110/robolectric-annotations-3.0.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.android.support/design/23.1.1/jars/classes.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.android.support/design/23.1.1/res:/home/daz/.gradle/caches/modules-2/files-2.1/org.robolectric/robolectric-utils/3.0/4bcecd8115fe7296088bb1636e6cbd7ae8927392/robolectric-utils-3.0.jar:/home/daz/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm-analysis/5.0.1/e286fbee48efacb4e7c175f7948d9d8b2ab52352/asm-analysis-5.0.1.jar:/home/daz/.gradle/caches/modules-2/files-2.1/com.twitter/twitter-text/1.13.0/78415b95ae3184c5926d593feab64bfc0b73b2dd/twitter-text-1.13.0.jar:/home/daz/.gradle/caches/modules-2/files-2.1/joda-time/joda-time/2.8/9f2785d7184b97d005a44241ccaf980f43b9ccdb/joda-time-2.8.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/facebook/build/intermediates/exploded-aar/com.android.support/multidex/1.0.1/jars/classes.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/facebook/build/intermediates/exploded-aar/com.android.support/multidex/1.0.1/res:/home/daz/.gradle/caches/modules-2/files-2.1/com.ximpleware/vtd-xml/2.11/ee5bcf62c1acf76434ee9f1c67a840bafef72a6d/vtd-xml-2.11.jar:/home/daz/.gradle/caches/modules-2/files-2.1/com.parse.bolts/bolts-applinks/1.3.0/bc535105332645408ef5f1380215cc954b842178/bolts-applinks-1.3.0.jar:/home/daz/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.1/860340562250678d1a344907ac75754e259cdb14/hamcrest-core-1.1.jar:/home/daz/.gradle/caches/modules-2/files-2.1/junit/junit/4.10/e4f1766ce7404a08f45d859fb9c226fc9e41a861/junit-4.10.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.google.android.gms/play-services-basement/8.4.0/res:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/exploded-aar/com.google.android.gms/play-services-basement/8.4.0/jars/classes.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/libs/segments_sdk_googleplaylib_1.6.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/facebook/build/intermediates/classes/test/debug:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/facebook/build/intermediates/classes/debug:/home/daz/.gradle/caches/modules-2/files-2.1/com.google.dexmaker/dexmaker/1.2/4d5045fefa6d286c5ddf733e321fe6e5e632efb6/dexmaker-1.2.jar:/home/daz/.gradle/caches/modules-2/files-2.1/org.powermock/powermock-module-junit4-rule/1.6.1/3f7c86f014ee9896261c5b94499f4038dfcd208c/powermock-module-junit4-rule-1.6.1.jar:/home/daz/.gradle/caches/modules-2/files-2.1/org.powermock/powermock-api-support/1.6.1/592ee6d929c324109d3469501222e0c76ccf0869/powermock-api-support-1.6.1.jar:/home/daz/.gradle/caches/modules-2/files-2.1/org.powermock/powermock-classloading-base/1.6.1/e44b2119014e47277547d060f55d5241831178b4/powermock-classloading-base-1.6.1.jar:/home/daz/.gradle/caches/modules-2/files-2.1/org.powermock/powermock-reflect/1.6.1/97d25eda8275c11161bcddda6ef8beabd534c878/powermock-reflect-1.6.1.jar:/home/daz/.gradle/caches/modules-2/files-2.1/xpp3/xpp3_min/1.1.4c/19d4e90b43059058f6e056f794f0ea4030d60b86/xpp3_min-1.1.4c.jar:/home/daz/.gradle/caches/modules-2/files-2.1/org.robolectric/shadows-support-v4/3.0/9261e07d142f2b488af628e2ddc3c39524fd77b/shadows-support-v4-3.0.jar:/home/daz/.gradle/caches/modules-2/files-2.1/com.google.dexmaker/dexmaker-mockito/1.2/b99884a4c6ef6335ba376f79aa79632b2421c17c/dexmaker-mockito-1.2.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/facebook/build/intermediates/exploded-aar/com.android.support/support-v4/23.0.1/res:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/facebook/build/intermediates/exploded-aar/com.android.support/support-v4/23.0.1/jars/classes.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/facebook/build/intermediates/exploded-aar/com.android.support/support-v4/23.0.1/jars/libs/internal_impl-23.0.1.jar:/home/daz/.gradle/caches/modules-2/files-2.1/org.mockito/mockito-core/1.10.19/e8546f5bef4e061d8dd73895b4e8f40e3fe6effe/mockito-core-1.10.19.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/facebook/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.0.1/jars/classes.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/facebook/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.0.1/res:/home/daz/.gradle/caches/modules-2/files-2.1/org.objenesis/objenesis/2.1/87c0ea803b69252868d09308b4618f766f135a96/objenesis-2.1.jar:/home/daz/.gradle/caches/modules-2/files-2.1/xmlpull/xmlpull/1.1.3.1/2b8e230d2ab644e4ecaa94db7cdedbc40c805dfa/xmlpull-1.1.3.1.jar:/media/development/android-sdk/adt-bundle-linux-x86_64-20131030/sdk/extras/android/m2repository/com/android/support/support-annotations/23.0.1/support-annotations-23.0.1.jar:/home/daz/.gradle/caches/modules-2/files-2.1/org.mockito/mockito-all/1.10.8/290232467869e43983cb6f269268aea2920c21b8/mockito-all-1.10.8.jar:/home/daz/.gradle/caches/modules-2/files-2.1/com.thoughtworks.xstream/xstream/1.4.2/97e5013f391487cce4de6b0eebcde21549e91872/xstream-1.4.2.jar:/home/daz/.gradle/caches/modules-2/files-2.1/org.powermock/powermock-core/1.6.1/5afc1efce8d44ed76b30af939657bd598e45d962/powermock-core-1.6.1.jar:/home/daz/.gradle/caches/modules-2/files-2.1/org.powermock/powermock-classloading-xstream/1.6.1/c88f7ba8b4c367261a601f782afd68408c05719b/powermock-classloading-xstream-1.6.1.jar:/home/daz/.gradle/caches/modules-2/files-2.1/org.powermock/powermock-api-mockito/1.6.1/82e69a577d593d410e999058648ab95c2cce763e/powermock-api-mockito-1.6.1.jar:/home/daz/.gradle/caches/modules-2/files-2.1/org.powermock/powermock-module-junit4-common/1.6.1/7222ced54dabc310895d02e45c5428ca05193cda/powermock-module-junit4-common-1.6.1.jar:/home/daz/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.3/42a25dc3219429f0e5d060061f71acb49bf010a0/hamcrest-core-1.3.jar:/home/daz/.gradle/caches/modules-2/files-2.1/org.javassist/javassist/3.18.2-GA/1180a90fbad732b60fb728a6bbe8fcb3151423d7/javassist-3.18.2-GA.jar:/home/daz/.gradle/caches/modules-2/files-2.1/junit/junit/4.12/2973d150c0dc1fefe998f834810d68f278ea58ec/junit-4.12.jar:/home/daz/.gradle/caches/modules-2/files-2.1/org.powermock/powermock-module-junit4/1.6.1/ea8530b2848542624f110a393513af397b37b9cf/powermock-module-junit4-1.6.1.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/dialoghelperlibrary/build/intermediates/classes/debug:/media/development/android-sdk/adt-bundle-linux-x86_64-20131030/sdk/platforms/android-23/optional/org.apache.http.legacy.jar:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/sourceFolderJavaResources/test/drunk_mode/debug:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/dialoghelperlibrary/build/intermediates/sourceFolderJavaResources/debug:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/facebook/build/intermediates/sourceFolderJavaResources/debug:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/DrunkMode/build/intermediates/sourceFolderJavaResources/drunk_mode/debug:/media/development/source/xmode/drunkmodeandroid/DrunkModeAS/build/generated/mockable-android-23.jar" com.intellij.rt.execution.application.AppMain com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 com.launch.drunkmodenew.userprofile.UserProfileScreenTest
WARNING: no system properties value for persist.radio.multisim.config
java.lang.UnsatisfiedLinkError: no javacrypto in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1864)
    at java.lang.Runtime.loadLibrary0(Runtime.java:870)
    at java.lang.System.loadLibrary(System.java:1122)
    at com.android.org.conscrypt.NativeCrypto.<clinit>(NativeCrypto.java:55)
    at com.android.org.conscrypt.AbstractSessionContext.<init>(AbstractSessionContext.java:44)
    at com.android.org.conscrypt.ClientSessionContext.<init>(ClientSessionContext.java:39)
    at com.android.org.conscrypt.OpenSSLContextImpl.<init>(OpenSSLContextImpl.java:50)
    at android.net.SSLCertificateSocketFactory.makeSocketFactory(SSLCertificateSocketFactory.java:205)
    at android.net.SSLCertificateSocketFactory.getDelegate(SSLCertificateSocketFactory.java:234)
    at android.net.SSLCertificateSocketFactory.createSocket(SSLCertificateSocketFactory.java:429)
    at com.squareup.okhttp.Connection.connectTls(Connection.java:224)
    at com.squareup.okhttp.Connection.connectSocket(Connection.java:199)
    at com.squareup.okhttp.Connection.connect(Connection.java:172)
    at com.squareup.okhttp.Connection.connectAndSetOwner(Connection.java:367)
    at com.squareup.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:128)
    at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:328)
    at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:245)
    at com.squareup.okhttp.Call.getResponse(Call.java:267)
    at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:224)
    at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:195)
    at com.squareup.okhttp.Call.execute(Call.java:79)
    at com.parse.ParseOkHttpClient.executeInternal(ParseOkHttpClient.java:69)
    at com.parse.ParseHttpClient$ParseNetworkInterceptorChain.proceed(ParseHttpClient.java:158)
    at com.parse.ParsePlugins$1.intercept(ParsePlugins.java:115)
    at com.parse.ParseHttpClient$ParseNetworkInterceptorChain.proceed(ParseHttpClient.java:147)
    at com.parse.ParseHttpClient.execute(ParseHttpClient.java:122)
    at com.parse.ParseRequest$3.then(ParseRequest.java:135)
    at com.parse.ParseRequest$3.then(ParseRequest.java:132)
    at bolts.Task$15.run(Task.java:839)
    at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
    at bolts.Task.completeAfterTask(Task.java:830)
    at bolts.Task.continueWithTask(Task.java:642)
    at bolts.Task.continueWithTask(Task.java:653)
    at bolts.Task$13.then(Task.java:745)
    at bolts.Task$13.then(Task.java:733)
    at bolts.Task$15.run(Task.java:839)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
java.lang.NoClassDefFoundError: Could not initialize class com.android.org.conscrypt.NativeCrypto
    at com.android.org.conscrypt.AbstractSessionContext.<init>(AbstractSessionContext.java:44)
    at com.android.org.conscrypt.ClientSessionContext.<init>(ClientSessionContext.java:39)
    at com.android.org.conscrypt.OpenSSLContextImpl.<init>(OpenSSLContextImpl.java:50)
    at android.net.SSLCertificateSocketFactory.makeSocketFactory(SSLCertificateSocketFactory.java:205)
    at android.net.SSLCertificateSocketFactory.getDelegate(SSLCertificateSocketFactory.java:234)
    at android.net.SSLCertificateSocketFactory.createSocket(SSLCertificateSocketFactory.java:429)
    at com.squareup.okhttp.Connection.connectTls(Connection.java:224)
    at com.squareup.okhttp.Connection.connectSocket(Connection.java:199)
    at com.squareup.okhttp.Connection.connect(Connection.java:172)
    at com.squareup.okhttp.Connection.connectAndSetOwner(Connection.java:367)
    at com.squareup.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:128)
    at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:328)
    at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:245)
    at com.squareup.okhttp.Call.getResponse(Call.java:267)
    at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:224)
    at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:195)
    at com.squareup.okhttp.Call.execute(Call.java:79)
    at com.parse.ParseOkHttpClient.executeInternal(ParseOkHttpClient.java:69)
    at com.parse.ParseHttpClient$ParseNetworkInterceptorChain.proceed(ParseHttpClient.java:158)
    at com.parse.ParsePlugins$1.intercept(ParsePlugins.java:115)
    at com.parse.ParseHttpClient$ParseNetworkInterceptorChain.proceed(ParseHttpClient.java:147)
    at com.parse.ParseHttpClient.execute(ParseHttpClient.java:122)
    at com.parse.ParseRequest$3.then(ParseRequest.java:135)
    at com.parse.ParseRequest$3.then(ParseRequest.java:132)
    at bolts.Task$15.run(Task.java:839)
    at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
    at bolts.Task.completeAfterTask(Task.java:830)
    at bolts.Task.continueWithTask(Task.java:642)
    at bolts.Task.continueWithTask(Task.java:653)
    at bolts.Task$13.then(Task.java:745)
    at bolts.Task$13.then(Task.java:733)
    at bolts.Task$15.run(Task.java:839)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

@kingargyle
Copy link
Contributor

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.

@jcogilvie
Copy link

I'm sure we all know how to write tests, and know what the difference
between a unit and an integration test is.

However, robolectric has a lot of code that works at the Fragment or
Activity level, so it would be nice to start Fragments or Activities that
depend on native code without having to go back and modify them for
testability.

Personally, I'm coming at this from the approach of adding tests to legacy
code, which statically loads JNI classes of dubious pedigree. It would be
nice to be able to test them as-is before trying to factor the NDK stuff
out.

On Fri, Mar 11, 2016 at 1:44 PM, David Carver notifications@github.com
wrote:

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.


Reply to this email directly or view it on GitHub
#1171 (comment)
.

@luckcoolla
Copy link

All DataManagers that use SnappyDB inside will be failed in test:

java.lang.UnsatisfiedLinkError: no snappydb-native in java.library.path at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857) at java.lang.Runtime.loadLibrary0(Runtime.java:870) at java.lang.System.loadLibrary(System.java:1119) at com.snappydb.internal.DBImpl.<clinit>(DBImpl.java:40) at com.snappydb.DBFactory.open(DBFactory.java:40) at com.snappydb.DBFactory.open(DBFactory.java:65)

@niltonvasques
Copy link

niltonvasques commented Nov 14, 2016

+1

@RyPope
Copy link

RyPope commented Nov 26, 2016

Running into this issue as well with android-database-sqlcipher

@zhengxiaopeng
Copy link

zhengxiaopeng commented Nov 27, 2016

In Robolectric testing framework, use your so library :

Support libraries that package native libraries

Summary

1. Disable load so in your app code.

2. Porting Dynamic Link Library.

  • If you use the Linux operating system that is the most simple, just get the x86-64(Depending on your cpu architecture) 's so file, and add the dependency so library(Found in the ndk-bundle, platforms folder).

  • If you use the masOS operating system, you need to do a little more work. And you should have the native so library source code, and compile it under macOS system:

# .o

cc -c -I/System/Library/Frameworks/JavaVM.framework/Headers *.cpp

# get  xxx.dylib

g++ -dynamiclib -undefined suppress -flat_namespace *.o -o something.dylib
  • Windows is similar.

3. Load so library in your RobolectricApplication.

End, run your test case, well done:

load so test case

Detail

Sample code: RobolectricSupportNativeLibs

blog - http://rocko.xyz/2016/11/27/Android-Robolectric-加载运行本地-so-动态库/

@xian xian removed the 2.4 label Jan 13, 2017
@xian xian added this to the to prioritize milestone Mar 2, 2017
@xian
Copy link
Member

xian commented Mar 2, 2017

Could someone provide a git repo or a pull request with a failing test for this?

@Kitter
Copy link

Kitter commented Sep 13, 2017

@zhengxiaopeng
As your comment, I run the test case ,but crash error occured.
OS:Centos7 x64
Android studio:2.3
screenshot from 2017-09-13 17-38-22

@ysaber
Copy link

ysaber commented Jul 27, 2018

Do we have any updates on this @xian ?

@djfos
Copy link

djfos commented Apr 17, 2019

If you run your test on Windows, you need to load the dll version of your library.
Here is my solution

@Before
fun ini(){
    Runtime.getRuntime().load("D:\\dev\\opencv\\opencv-4.0.1\\build\\java\\x64\\opencv_java401.dll")
}

use Runtime.getRuntime().load() to load a specific file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests