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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:13:43+00:00 2026-05-23T12:13:43+00:00

Me used Fragment of Android Compatibility Package, using the android-support-v4.jar . But I can’t

  • 0

Me used Fragment of Android Compatibility Package, using the android-support-v4.jar. But I can’t do the JUnit test on this.

My main FragmentActivity class is declared as follows

public class MyActivityClass extends FragmentActivity{
...............
}

Then in my test project

public class MyActivityClassTest extends ActivityInstrumentationTestCase2<MyActivityClass> {
    public MyActivityClassTest() {  
        super("com.android.myproject", MyActivityClass.class);
    }
    @Override
    protected void setUp() throws Exception {
        super.setUp();
        ...................
    }

    public void testPreconditions() {
        .................
    }
    public void testNotNull(){
        ................
    }
}

But when I run as Android JUnit Test produce FailedToCreateTests[Runner:Junit3]
Failure Trace

java.lang.RuntimeException: Exception during suite construction
at android.test.suitebuilder.TestSuiteBuilder$FailedToCreateTests.testSuiteConstructionFailed(TestSuiteBuilder.java:239)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:430)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)
Caused by: java.lang.reflect.InvocationTargetException
at com.android.myproject.test.MyActivityClassTest.<init>(MyActivityClassTest.java:28)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
at android.test.suitebuilder.TestMethod.instantiateTest(TestMethod.java:87)
at android.test.suitebuilder.TestMethod.createTest(TestMethod.java:73)
at android.test.suitebuilder.TestSuiteBuilder.addTest(TestSuiteBuilder.java:263)
at android.test.suitebuilder.TestSuiteBuilder.build(TestSuiteBuilder.java:185)
at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:336)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3982)
at android.app.ActivityThread.access$2900(ActivityThread.java:119)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1901)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4363)
at java.lang.reflect.Method.invokeNative(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoClassDefFoundError: com.android.myproject.MyActivityClass
... 19 more

When I changed MyActivityClass to extends Activity it worked fine (MyActivityClass extends Activity)
Me used the same android-support-v4.jar in my both test and main project

  • 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-23T12:13:44+00:00Added an answer on May 23, 2026 at 12:13 pm

    I found a solution

    The problem was

    Caused by: java.lang.NoClassDefFoundError: com.android.myproject.MyActivityClass
    

    It cannot find the class path even though I refer the same jar in both projects ( I also tried by using separate jar for both the project )

    Now, I created my testing environment in the same project, then it worked

    In my AndroidManifest.xml

    <manifest...>
        <!-- For doing JUnit test, Instrumentation Start (remove later) -->
        <instrumentation
            android:targetPackage="com.pe.android.isccasinos"
            android:name="android.test.InstrumentationTestRunner" />
        <!-- For doing JUnit test, Instrumentation End (remove later) -->   
        <application ...>
        ................
        <!-- For doing JUnit test, add library starting (remove later) -->
            <uses-library
                android:name="android.test.runner" />
            <!-- For doing JUnit test, add library ending (remove later) -->
        </application>
    <manifest>
    

    Then I added my Testing class in my special package for testing

    extends ActivityInstrumentationTestCase2<fragmentActivity>
    

    Now everything is working fine 🙂

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

Sidebar

Related Questions

Can Html Agility Pack be used to parse an html string fragment? Such As:
I'm using the Android compatibility library, targeting Android 2.2. If I use ListFragment With
i am implementing a splitview using the new fragment from Google (Android 3). when
When creating an Android application using Loaders, should every activity and fragment have its
I wanted to know if a single document fragment can be used to insert
I have created swipey tabs using ViewPagerExtensions but this time i am using only
I used a FragmentTransaction to add a Fragment into a FrameLayout. I want to
In the example on using fragments in the Android docs, when the application is
I'm trying to validate an Xml fragment using an Xml Schema with the XDocument.Validate
I know Python but I've never used Django. What do I need to know

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.