7

I've added a reference to a new module and try to open an Activity from it. It throws an Exception that says:

android.content.ActivityNotFoundException: Unable to find explicit activity class{
com.giljulio.imagepicker.ui/com.giljulio.imagepicker.ui.ImagePickerActivity };

have you declared this activity in your AndroidManifest.xml?

Do I need to add anything else beside reference the new module?

Android
  • 1,420
  • 4
  • 13
  • 23
EitanG
  • 221
  • 4
  • 19
  • Did you in fact add the activity to your AndroidManifest.xml? – mt523 Jul 30 '14 at 17:34
  • 1
    You can check this. http://stackoverflow.com/questions/16545725/try-to-start-library-project-activity – santilod Jul 30 '14 at 17:36
  • declare ImagePickerActivity activity in the Manifest... – Rajesh Mikkilineni Jul 30 '14 at 17:37
  • Thanks. It was really not define in my AndroidManifest, But, maybe I don't understand something, I want to use a github project ( https://github.com/giljulio/android-multiple-image-picker ), If I import this module to my project I need to call it's main activity ? when I do so, it throw an exception that it doen not recognize some of it R.id's. the module manifest is : – EitanG Jul 30 '14 at 17:59

3 Answers3

6

You have to define in gradle dependencies(in module where you want to call another module activity):

dependencies{
     ...
     compile project(':yourModuleName')
     ...
}

After adding this sync the gradle and now can you use the activity in the module.

arpit
  • 1,462
  • 1
  • 12
  • 12
2

User like this. This will help you

Intent intent = null;
try {
    intent = new Intent(this, 
       Class.forName("ir.test.testlibary1.HelloWorldActivity"));
    startActivity(intent);
} catch (ClassNotFoundException e) {
    e.printStackTrace();
}
Aman Kumar
  • 23
  • 4
0

Ok, so I am a few years late.

The issue is not that you don't have the gradle dependency as @arpit suggested, it seems you report a runtime exception. Also, what @Aman suggested will help with the handling the exception, it will just not help you start the activity.

If understood correctly, you have a multi-module app (let's say A-app module and B-lib module) and need to call another lib-module(C) from one B.

If that is the case, you need to declare that library's activity(C) in your module's(B) Manifest.xml, inside the tag.

If it has not already been setup, you also need to enable manifest merger.

barmacki
  • 31
  • 6