Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8190335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:35:30+00:00 2026-06-07T03:35:30+00:00

The Application object for my Android app loads a JNI library, and Robolectric doesn’t

  • 0

The Application object for my Android app loads a JNI library, and Robolectric doesn’t seem to like that. When I go to run my tests Robolectric craps out and I get this stack trace:

java.lang.UnsatisfiedLinkError: no cperryinc-jni in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1758) at
java.lang.Runtime.loadLibrary0(Runtime.java:823) at
java.lang.System.loadLibrary(System.java:1045) at
com.cperryinc.application.MoolaApplication.(MoolaApplication.java:24)
at java.lang.Class.forName0(Native Method) at
java.lang.Class.forName(Class.java:169) at
com.xtremelabs.robolectric.internal.ClassNameResolver.safeClassForName(ClassNameResolver.java:36)
at
com.xtremelabs.robolectric.internal.ClassNameResolver.resolve(ClassNameResolver.java:15)
at
com.xtremelabs.robolectric.ApplicationResolver.newApplicationInstance(ApplicationResolver.java:71)
at
com.xtremelabs.robolectric.ApplicationResolver.resolveApplication(ApplicationResolver.java:28)
at
com.xtremelabs.robolectric.RobolectricTestRunner.createApplication(RobolectricTestRunner.java:483)
at
com.xtremelabs.robolectric.RobolectricTestRunner.setupApplicationState(RobolectricTestRunner.java:360)
at
com.xtremelabs.robolectric.RobolectricTestRunner.internalBeforeTest(RobolectricTestRunner.java:299)
at
com.xtremelabs.robolectric.RobolectricTestRunner.methodBlock(RobolectricTestRunner.java:277)
at
org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at
org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at
org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at
org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at
org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at
org.junit.runners.ParentRunner.run(ParentRunner.java:236) at
org.junit.runner.JUnitCore.run(JUnitCore.java:157) at
com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:76)
at
com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:182)
at
com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:62)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

I’m not exactly sure what I can do about this. Any ideas on a workaround?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T03:35:33+00:00Added an answer on June 7, 2026 at 3:35 am

    Solution works for Robolectric 1.2, not 2.+

    Thanks to Jan Berkel for answering this here:
    https://groups.google.com/d/msg/robolectric/beW9XjT8E1A/pJQrRaybN30J

    class MyJniClass {
     static {
            try {
                System.loadLibrary("libname");
            } catch (UnsatisfiedLinkError e) {
                // only ignore exception in non-android env
                if ("Dalvik".equals(System.getProperty("java.vm.name"))) throw e;
            }
        }
    }
    

    then in the testrunner:

    public class MyTestRunner  extends RobolectricTestRunner {
       public MyTestRunner(Class testClass) throws InitializationError {
             // remove native calls + replace with shadows
            addClassOrPackageToInstrument("com.example.jni.MyJniClass");
       }
    
       protected void bindShadowClasses() {
             // bind shadow JNI classes
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got an android application using a shared object in the JNI (that I
I am building an android application that has an Application object ( App )
I'd like to extend Application in my Android app. I've done this such that
I have a simple html/javascript based Android app that loads with the following code:
I have read about application object in android site but I couldn't understand. What
It's about android application memory leak of Thread object. I didn't know yet following
I am making an application in Android, which requires sending bitmap object from one
I am working on a sketchpad android application. I am using a path object
In my Android app I have a service that is started via AlarmManager. I
I am working on an Android app that uses the gdata-java-client to download documents

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.