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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:02:54+00:00 2026-05-28T03:02:54+00:00

I get a java.lang.NoClassDefFoundError: android/util/Log error when I try to run my unit test

  • 0

I get a java.lang.NoClassDefFoundError: android/util/Log error when I try to run my unit test project in eclipse.

Distilled down, my test code looks like this:

package com.randomtype.yycparking;

import junit.framework.TestCase;
import android.util.Log;

public class StallTests extends TestCase {  
    public void setUp() {
        Log.v("HI", "Fail");
    }

    public void testShouldParseIdFromTitle() {
        assertTrue(true);
    }
}

And the code throws an exception on the Log.v call. When I run the android project normally I don’t get any exceptions around Log.

Full Stack Trace:

java.lang.NoClassDefFoundError: android/util/Log
    at com.randomtype.yycparking.StallTests.setUp(StallTests.java:11)
    at junit.framework.TestCase.runBare(TestCase.java:132)
    at junit.framework.TestResult$1.protect(TestResult.java:110)
    at junit.framework.TestResult.runProtected(TestResult.java:128)
    at junit.framework.TestResult.run(TestResult.java:113)
    at junit.framework.TestCase.run(TestCase.java:124)
    at junit.framework.TestSuite.runTest(TestSuite.java:243)
    at junit.framework.TestSuite.run(TestSuite.java:238)
    at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassNotFoundException: android.util.Log
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    ... 14 more

As pointed out by dtmilano, I wasn’t running the unit tests as an Android JUnit Test. How can you tell the difference? Look for the little a like in the picture below:

Screen shot of a beside JUnit icon
(source: skitch.com)

  • 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-05-28T03:02:55+00:00Added an answer on May 28, 2026 at 3:02 am

    Your tests should be in a separate Android Test Project (Project -> Android Tools -> New Android Project) and you should run them as Android JUnit Test (Run as -> Android JUnit Test).

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

Sidebar

Related Questions

I get a java.lang.NoClassDefFoundError: com/hp/hpl/jena/shared/BadURIException when running a very simple servlet. The error points
I get a Java.Lang.NoClassDefFoundError error when creating an Intent of a custom class (an
I get this exception in Eclipse: java.lang.NoClassDefFoundError: org/eclipse/core/runtime/content/IContentTypeManager$IContentTypeChangeListener at java.lang.ClassLoader.defineClass1(Native Method) I added org.eclipse.core.runtime.jar
I get java.lang.NoClassDefFoundError when I add 3d party library to my project. I've tried
I get a java.lang.outOfMemoryError exception, while writing a big file to the servletOutputStream. Every
It doesn't seem to be working right now. I get a java.lang.NullPointerException I have
How can I get an equivalent of java.lang.Integer.MIN_VALUE on C++?
I get the following warning when using java.net.URLEncoder.encode : warning: [deprecation] encode(java.lang.String) in java.net.URLEncoder
I'm getting a java.lang.ClassNotFoundException: javax.ejb.EJBObject error when I'm running my application as a JAR
I'm using Eclipse to manage my Android project, which uses Amazon's Android libraries for

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.