android:如何启动库项目中定义的活动

时间:2012-04-04 11:17:19

标签: android android-activity android-library

我正在开发一个使用androidVNC Viewer作为库项目的android应用程序,但我无法从androidVNC启动活动(找不到活动异常)。

另外,如何捆绑一个库项目并将其用作一个apk?

更新

我正在使用以下意图致电:

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

更新2 使用下面的代码后,我想我可以开始活动,但得到这个(java.lang.NoSuchFieldError:android.androidVNC.R $ id.textIP)错误......

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

我检查了R.java,androidVNC原创和androidVNC用作库(在生成的java文件下)...我得到的是 textip是在orignal R.java 但它是在调用项目的 R.java(生成的java文件)中没有。

logcat的O / P(前几行)


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)

任何线索?

2 个答案:

答案 0 :(得分:7)

即使库项目有自己的AndroidManifest.xml,其内容也不会添加到您的构建中。如果您计划使用库中包含的通常在清单中声明的​​任何内容,则必须将其复制到实际的应用程序清单中。这包括活动,广播接收者,服务,许可等。

答案 1 :(得分:2)

假设lib和app具有不同的名称空间:

当将lib-manifest-info与app-manifest合并为mah时,你是否在活动中包含了不同的命名空间?

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

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

使用最新的eclipse-android工具1.7也可能有所帮助。有关详细信息,请参阅how-to-consume-reusable-gui-element-widget-with-resources-in-android