5

I am developing an android application that uses androidVNC Viewer as a library project, but I am unable to launch an activity from androidVNC (activity not found exception).

Also, how do I bundle a library project and use it as one apk?

UPDATE

I am using following intent to call:

Intent call= new Intent("android.androidVNC.androidVNC.LAUNCH");
startActivity(call);

UPDATE 2 after using following code i think i could start the activity but getting this ( java.lang.NoSuchFieldError: android.androidVNC.R$id.textIP) error...

Intent vnc_call = new Intent(getApplicationContext(), androidVNC.class);
            vnc_call.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(login);

after i checked both R.java,androidVNC original and androidVNC when used as library(under generated java files)...what i got is textip is there in orignal R.java but it is not there in the R.java of (generated java files) in the calling project.

O/P of logcat (first few lines)


04-05 01:34:18.135: W/dalvikvm(479): Unable to resolve superclass of Landroid/androidVNC/AbstractConnectionBean; (256)
04-05 01:34:18.135: W/dalvikvm(479): Link of class 'Landroid/androidVNC/AbstractConnectionBean;' failed
04-05 01:34:18.135: W/dalvikvm(479): Unable to resolve superclass of Landroid/androidVNC/ConnectionBean; (8)
04-05 01:34:18.135: W/dalvikvm(479): Link of class 'Landroid/androidVNC/ConnectionBean;' failed
04-05 01:34:18.145: W/dalvikvm(479): VFY: unable to find class referenced in signature (Landroid/androidVNC/ConnectionBean;)
04-05 01:34:18.155: W/dalvikvm(479): Unable to resolve superclass of Landroid/androidVNC/AbstractConnectionBean; (256)
04-05 01:34:18.155: W/dalvikvm(479): Link of class 'Landroid/androidVNC/AbstractConnectionBean;' failed
04-05 01:34:18.155: W/dalvikvm(479): Unable to resolve superclass of Landroid/androidVNC/ConnectionBean; (8)
04-05 01:34:18.155: W/dalvikvm(479): Link of class 'Landroid/androidVNC/ConnectionBean;' failed
04-05 01:34:18.187: W/dalvikvm(479): Unable to resolve superclass of Landroid/androidVNC/AbstractConnectionBean; (256)
04-05 01:34:18.187: W/dalvikvm(479): Link of class 'Landroid/androidVNC/AbstractConnectionBean;' failed
04-05 01:34:18.187: W/dalvikvm(479): Unable to resolve superclass of Landroid/androidVNC/ConnectionBean; (8)`

04-05 01:34:18.135: W/dalvikvm(479): Unable to resolve superclass of Landroid/androidVNC/AbstractConnectionBean; (256)
04-05 01:34:18.135: W/dalvikvm(479): Link of class 'Landroid/androidVNC/AbstractConnectionBean;' failed
04-05 01:34:18.135: W/dalvikvm(479): Unable to resolve superclass of Landroid/androidVNC/ConnectionBean; (8)
04-05 01:34:18.135: W/dalvikvm(479): Link of class 'Landroid/androidVNC/ConnectionBean;' failed
04-05 01:34:18.145: W/dalvikvm(479): VFY: unable to find class referenced in signature (Landroid/androidVNC/ConnectionBean;)
04-05 01:34:18.155: W/dalvikvm(479): Unable to resolve superclass of Landroid/androidVNC/AbstractConnectionBean; (256)
04-05 01:34:18.155: W/dalvikvm(479): Link of class 'Landroid/androidVNC/AbstractConnectionBean;' failed
04-05 01:34:18.155: W/dalvikvm(479): Unable to resolve superclass of Landroid/androidVNC/ConnectionBean; (8)
04-05 01:34:18.155: W/dalvikvm(479): Link of class 'Landroid/androidVNC/ConnectionBean;' failed
04-05 01:34:18.187: W/dalvikvm(479): Unable to resolve superclass of Landroid/androidVNC/AbstractConnectionBean; (256)
04-05 01:34:18.187: W/dalvikvm(479): Link of class 'Landroid/androidVNC/AbstractConnectionBean;' failed
04-05 01:34:18.187: W/dalvikvm(479): Unable to resolve superclass of Landroid/androidVNC/ConnectionBean; (8)

any clue?

Sanyprashant
  • 59
  • 1
  • 1
  • 3

2 Answers2

8

Even though library projects have their own AndroidManifest.xml, its contents are not added to your build. Anything the library contains which is normally declared in the manifest must be copied to your actual application manifest if you plan to make use of them. This includes activities, broadcast receivers, services, permissions, etc.

mah
  • 39,056
  • 9
  • 76
  • 93
  • thanks for your reply, i have included everything already...but still getting activity not found exception.. – Sanyprashant Apr 04 '12 at 11:57
  • 2
    Based on your updated code, you're not starting the activity by its class name, you're starting it based on its action. Does your activity entry in the manifest include an `` section, with an action such as ``? If not, this is why you're unable to find the activity. You can either change the manifest to declare the action in the intent-filter (you might also need to add `` to the filter, I'm not sure) or change how you define your Intent. – mah Apr 04 '12 at 15:25
  • thanks, but it didnt help...even i use {Intent call = new Intent(getApplicationContext(), android.androidVNC.androidVNC.class);} i am getting same error.. – Sanyprashant Apr 04 '12 at 19:26
  • Android Studio now merges the AndroidManifest.xml files and resources the way you would expect it to. So you can now define your library activities in the library AndroidManifest.xml. – respectTheCode May 14 '14 at 13:28
  • @mah are you sure you need to define Broadcast receivers in the manifest? I have used a BroadcastReceiver to get USB notifications in a library project and it is not defined in either the main application's manifest (the application using the library) or the library's manifest. But then again, the behavior of Android's USB is so weird that fact that it works there could be a quirk of the USB. – Brian Reinhold Jan 24 '16 at 11:49
  • @BrianReinhold I don't know the state of things today, but the state when I answered 3 years ago was that you must either declare a static BR a infest (and a library manifest was insufficient) OR you can install a dynamic one at runtime. A static receiver is necessary when it should be activated without something starting the app to run the dynamic installation first. – mah Jan 24 '16 at 23:00
  • @mah I see. My BRs are dynamic and only are in action when the service is started. That maybe the reason. I have two, one catching BT and another catching USB events. – Brian Reinhold Jan 25 '16 at 09:03
2

assuming that lib and app have different namespaces:

when merging the lib-manifest-info with the app-manifest as mah described, did you include different namespaces in the activity ?

    <application ... >
        <activity
            android:name=".MyActivity" >...

to

    <application ... >
        <activity
            android:name="my.namespace.MyActivity" >...

using latest eclipse-android tools 1.7 may also help. See how-to-consume-reusable-gui-element-widget-with-resources-in-android for details

Community
  • 1
  • 1
k3b
  • 14,517
  • 7
  • 53
  • 85