[英]android : how to start activity defined in library project
我正在開發一個 android 應用程序,它使用 androidVNC Viewer 作為庫項目,但我無法從 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);
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項目。
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)
任何線索?
即使庫項目有自己的 AndroidManifest.xml,它的內容也不會添加到您的構建中。 如果您打算使用庫包含的任何通常在清單中聲明的內容,則必須將它們復制到您的實際應用程序清單中。 這包括活動、廣播接收器、服務、權限等。
假設 lib 和 app 有不同的命名空間:
當按照 mah 的描述將 lib-manifest-info 與 app-manifest 合並時,您是否在活動中包含了不同的名稱空間?
<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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.