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 8643063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:56:21+00:00 2026-06-12T11:56:21+00:00

I am trying to get Mockito (1.9.5 rc1) working in my Android tests (using

  • 0

I am trying to get Mockito (1.9.5 rc1) working in my Android tests (using Robotium). For making it run on the DVM I put dexmaker.jar and the dexmaker-mockito.jar (v 0.9) in the classpath of the test-project.

When run following test as an Android JUnit test in Eclipse:

package com.stampay.pos.test;

import roboguice.RoboGuice;
import android.app.Application;

import com.jayway.android.robotium.solo.Solo;
import com.stampay.pos.activities.HomeActivity;
import com.stampay.pos.model.Consumer;
import com.stampay.pos.util.ScannerAndroid;

import static org.mockito.Mockito.*;

public class HomeActivityTest extends ActivityTest<HomeActivity> {
    private Solo solo;
    Application app;

    public HomeActivityTest() {
        super(HomeActivity.class);

    }

    @Override
    public void setUp() throws Exception {
        solo = new Solo(getInstrumentation(), getActivity());
    }

    @Override
    public void tearDown() throws Exception {
        solo.finishOpenedActivities();
        RoboGuice.util.reset();
    }

    public void testScan() throws Exception {

        ScannerAndroid scanner = (ScannerAndroid) getActivity().getScannerHelper();

        Consumer mockConsumer = mock(Consumer.class);

        //scanner.generateResult("consumer1");
    }
}

I get the following stack trace:

java.lang.ExceptionInInitializerError
at com.stampay.pos.test.HomeActivityTest.testScan(HomeActivityTest.java:41)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:192)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:190)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:175)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1584)
Caused by: java.lang.ExceptionInInitializerError
at org.mockito.internal.MockitoCore.<init>(MockitoCore.java:40)
at org.mockito.Mockito.<clinit>(Mockito.java:932)
... 15 more
Caused by: java.lang.ExceptionInInitializerError
at org.mockito.internal.util.MockUtil.<clinit>(MockUtil.java:21)
... 17 more
Caused by: org.mockito.exceptions.misusing.MockitoConfigurationException: Failed to load interface org.mockito.plugins.MockMaker using jar:file:/data/app/com.stampay.pos.test-2.apk!/mockito-extensions/org.mockito.plugins.MockMaker
... 15 more
Caused by: java.lang.ClassNotFoundException: com.google.dexmaker.mockito.DexmakerMockMaker
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at org.mockito.internal.configuration.ClassPathLoader.loadImplementations(ClassPathLoader.java:133)
at org.mockito.internal.configuration.ClassPathLoader.findPlatformMockMaker(ClassPathLoader.java:102)
at org.mockito.internal.configuration.ClassPathLoader.<clinit>(ClassPathLoader.java:61)
at org.mockito.internal.util.MockUtil.<clinit>(MockUtil.java:21)
at org.mockito.internal.MockitoCore.<init>(MockitoCore.java:40)
at org.mockito.Mockito.<clinit>(Mockito.java:932)
... 15 more

Any suggestions? http://code.google.com/p/dexmaker/ and http://code.google.com/p/mockito/wiki/ReleaseNotes do not provide any helpful information.

A similar problem seems to be reported here: http://www.paulbutcher.com/2012/05/mockito-on-android-step-by-step/#comment-65955

UPDATE:
with the .jar files from https://github.com/paulbutcher/mockito-on-android/tree/master/WarehouseManagerTest/libs all works smoothly, though he uses an outdated snapshot of Mockito based on 1.9.1

  • 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-12T11:56:22+00:00Added an answer on June 12, 2026 at 11:56 am

    I encountered the same problem attempting to use mockito 1.9.5-rc1.

    The dexmaker page notes that you need 1.9.5+ for this, and apparently RC1 doesn’t cut it. Mockito 1.9.5 appears to have just been released days ago, so it should show up shortly in Maven Central.

    In the meantime, you can download the 1.9.5 zip from Mockito’s site. If you’re using Maven, you could manually install those jars to your local repo with mvn install:install-file. I also got this to work by checking out the latest Mockito source (unreleased 1.9.8), building, and installing to my local Maven repo.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to get to mock a method with vararg parameters using Mockito:
I am trying get all html links within a string and replace them using
I am trying get all html links within a string and replace them using
I am trying get Struts 2 and Tiles to work and I am using
I am trying get the values using SP.The query is below. create proc [dbo].[GetOrdersByUserID11]
I am trying get my head around how you can run the following php:
I'm trying get some licensing code from AndroidPit.com working, but I get Unable to
Hello everyone I been trying get php uploader working but having a lot of
I am using cakephp. I am trying get data from facebook using file_get_contents. I
I'm trying get bytes from bitmap in blackberry using the next method in Bitmap:

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.