2012-06-12 63 views
0

這是我第一次使用Android/Java。我試圖運行此基本代碼,我不斷收到以下錯誤:Android/Eclipse錯誤 - 「無法找到類'org.jivesoftware.smack.ConnectionConfiguration',引用方法」

「找不到類‘org.jivesoftware.smack.ConnectionConfiguration’,從方法中引用」

  • 我代碼:

    package message.pack; 
    import org.jivesoftware.smack.ConnectionConfiguration; 
    import org.jivesoftware.smack.XMPPConnection; 
    import org.jivesoftware.smack.XMPPException; 
    
    import android.app.Activity; 
    import android.os.Bundle; 
    
    public class ThesimpleigniteandroidActivity extends Activity { 
        /** Called when the activity is first created. */ 
        @Override 
        public void onCreate(Bundle savedInstanceState) { 
         super.onCreate(savedInstanceState); 
         setContentView(R.layout.main); 
    
        } 
    
           public static void main(String[] args) { 
           ConnectionConfiguration conf = new  ConnectionConfiguration("jabber.com",5222); 
           XMPPConnection connection = new XMPPConnection(conf); 
            try { 
            connection.connect(); 
            connection.login("myusername", "mypassword"); 
            } catch (XMPPException e) { 
            e.printStackTrace(); 
            } finally { 
              connection.disconnect(); 
            } 
            } 
            } 
    

我使用smack.jar從這個頁面:

http://vidorsolutions.blogspot.com/2011/01/writing-xmppjabber-chat-application-for.html?m=1

有誰能告訴我我做錯了什麼嗎?

+0

使用smack.jar?它是否包含必需的類? –

回答

6

這類似於圍繞Android的項目外罐(特別是與新的SDK工具)很多相關問題。解決方案是讓您在項目中創建一個名爲libs的文件夾,然後將jar複製到該文件夾​​中。

+0

這是解決方案。謝謝! – user1447979

相關問題