我將第一個項目添加爲庫。然後,我將這個庫添加到第二個項目。現在,在第二個項目中,我需要從第一個項目中的一個活動轉移到另一個項目(該步驟中的應用程序崩潰,但是兩個項目都運行良好)。我嘗試了這種鏈接http://developer.android.com/tools/projects/projects-eclipse.html步驟,但沒有任何更改。此外,我試圖將第一個項目的文件添加到第二個項目,但同樣的問題出現。 logcat的錯誤:如何在eclipse上結合2個Android項目?
09-02 19:33:21.437: E/AndroidRuntime(27777): FATAL EXCEPTION: main
09-02 19:33:21.437: E/AndroidRuntime(27777): Process: com.vatrina.eg, PID: 27777
09-02 19:33:21.437: E/AndroidRuntime(27777): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.vatrina.eg/com.vatrina.eg.CustomizedListView}: android.os.NetworkOnMainThreadException
09-02 19:33:21.437: E/AndroidRuntime(27777): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2305)
09-02 19:33:21.437: E/AndroidRuntime(27777): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363)
09-02 19:33:21.437: E/AndroidRuntime(27777): at android.app.ActivityThread.access$900(ActivityThread.java:161)
09-02 19:33:21.437: E/AndroidRuntime(27777): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
09-02 19:33:21.437: E/AndroidRuntime(27777): at android.os.Handler.dispatchMessage(Handler.java:102)
09-02 19:33:21.437: E/AndroidRuntime(27777): at android.os.Looper.loop(Looper.java:157)
09-02 19:33:21.437: E/AndroidRuntime(27777): at android.app.ActivityThread.main(ActivityThread.java:5356)
09-02 19:33:21.437: E/AndroidRuntime(27777): at java.lang.reflect.Method.invokeNative(Native Method)
09-02 19:33:21.437: E/AndroidRuntime(27777): at java.lang.reflect.Method.invoke(Method.java:515)
09-02 19:33:21.437: E/AndroidRuntime(27777): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
09-02 19:33:21.437: E/AndroidRuntime(27777): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
09-02 19:33:21.437: E/AndroidRuntime(27777): at dalvik.system.NativeStart.main(Native Method)
09-02 19:33:21.437: E/AndroidRuntime(27777): Caused by: android.os.NetworkOnMainThreadException
09-02 19:33:21.437: E/AndroidRuntime(27777): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1156)
09-02 19:33:21.437: E/AndroidRuntime(27777): at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
09-02 19:33:21.437: E/AndroidRuntime(27777): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
09-02 19:33:21.437: E/AndroidRuntime(27777): at java.net.InetAddress.getAllByName(InetAddress.java:214)
09-02 19:33:21.437: E/AndroidRuntime(27777): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
09-02 19:33:21.437: E/AndroidRuntime(27777): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
09-02 19:33:21.437: E/AndroidRuntime(27777): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
09-02 19:33:21.437: E/AndroidRuntime(27777): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
09-02 19:33:21.437: E/AndroidRuntime(27777): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:670)
09-02 19:33:21.437: E/AndroidRuntime(27777): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:509)
09-02 19:33:21.437: E/AndroidRuntime(27777): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
09-02 19:33:21.437: E/AndroidRuntime(27777): at com.vatrina.eg.XMLParser.getXmlFromUrl(XMLParser.java:45)
09-02 19:33:21.437: E/AndroidRuntime(27777): at com.vatrina.eg.CustomizedListView.onCreate(CustomizedListView.java:41)
09-02 19:33:21.437: E/AndroidRuntime(27777): at android.app.Activity.performCreate(Activity.java:5426)
09-02 19:33:21.437: E/AndroidRuntime(27777): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
09-02 19:33:21.437: E/AndroidRuntime(27777): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269)
09-02 19:33:21.437: E/AndroidRuntime(27777): ... 11 more
嗨,歡迎來到Stackoverflow :),發佈一些代碼和顯示在LogCat中的消息。 「第二,我需要從第一個項目的活動轉移到另一個活動」你的意思是說你試圖從圖書館加載一項活動? – Jorgesys 2014-09-02 16:23:59
感謝您的回覆。 :)完成。是的,我需要轉到圖書館的一項活動。 – 2014-09-02 16:41:15
你可以檢查你的代碼,並檢查你是否在UIThread上執行任何連接?我認爲這是問題。其中至少有一個。 – 2014-09-02 16:42:11