android : how to start activity defined in library project

南楼画角 提交于 2019-12-06 07:22:57

问题


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?


回答1:


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.




回答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



来源:https://stackoverflow.com/questions/10010013/android-how-to-start-activity-defined-in-library-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!