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

  • Home
  • SEARCH
  • 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 6702473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:03:30+00:00 2026-05-26T07:03:30+00:00

I have an activity (DemoAppActivity) from which I am trying to launch a different

  • 0

I have an activity (DemoAppActivity) from which I am trying to launch a different activity (MainActivity) when a button is pressed. However I am getting two errors:

1) when the app is loaded into the emulator, I see the following in the Android logs:

10-12 18:48:19.579: ERROR/dalvikvm(620): Could not find class 'com.example.android.hcgallery.MainActivity', referenced from method com.consultknapp.demoapp.DemoAppActivity$1.onClick

2) when i actually push the button that calls startActivity:

10-12 18:54:58.019: ERROR/AndroidRuntime(620): java.lang.NoClassDefFoundError: com.example.android.hcgallery.MainActivity

Here is how I am starting the activity (note: I import the class with an import statment, import com.example.android.hcgallery.MainActivity)

startActivity(new Intent(DemoAppActivity.this, MainActivity.class));

I have the MainActivity project folder in my build path in eclipse, and I even see it load the MainActivity.apk when I compile/run my DemoAppActivity. However, it bombs when I try to run it on the emulator.

What am I missing here? Do I need to jar up my MainActivity and include it in the DemoAppActivity somehow?

  • 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-26T07:03:30+00:00Added an answer on May 26, 2026 at 7:03 am

    I was able to figure it out from another post. Basically you need to do this with the Intent before starting the activity:

    Intent i = new Intent();
    i.setComponent(new ComponentName("com.example.android.hcgallery", "com.example.android.hcgallery.MainActivity"));
    startActivity(i);
    

    The setComponent tells the class loader to make it available. After adding that code, it worked!

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

Sidebar

Related Questions

I have one activity in which I am having one TabHost with two tabs.
I have activity which can show overlay. This overlay have markers which gets from
let's have activity A and button in that activity, which opens activity A again.
I have an Activity in Android, with two elements: EditText ListView When my Activity
I have an activity which shows some List entries. When I click on a
I have an activity with two buttons, start and stop. If the user press
I have activity A that starts activity B which starts activity C: A ->
I have an activity with a button that sends a pre-defined email. The button
I have an Activity with some buttons,if I click a specific button a new
I have 1 activity, but would like to have multiple context menu's for different

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.