Simplest possible code:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); SmackAndroid.init(this); // Create a connection to the jabber.org server. XMPPTCPConnection conn1 = new XMPPTCPConnection("xmpp-hosting.de"); try { conn1.connect(); } catch (SmackException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (XMPPException e) { // TODO Auto-generated catch block e.printStackTrace(); } Log.d(TAG, "Connected successfully!"); if (savedInstanceState == null) { getSupportFragmentManager().beginTransaction() .add(R.id.container, new PlaceholderFragment()).commit(); } }
But I get a NoClassDefFound Exception at init(). I noticed there are some warnings while building the app:
[2014-06-30 08:47:51 - AsmackTest] Dx warning: Ignoring InnerClasses attribute for an anonymous inner class (jnamed$1) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is *not* an inner class. [2014-06-30 08:47:51 - AsmackTest] Dx warning: Ignoring InnerClasses attribute for an anonymous inner class (jnamed$2) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is *not* an inner class. [2014-06-30 08:47:51 - AsmackTest] Dx warning: Ignoring InnerClasses attribute for an anonymous inner class (jnamed$3) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is *not* an inner class. [2014-06-30 08:47:52 - AsmackTest] Dx warning: Ignoring InnerClasses attribute for an anonymous inner class (org.xbill.DNS.UDPClient$1) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is *not* an inner class. [2014-06-30 08:47:53 - AsmackTest] Dx trouble processing: [2014-06-30 08:47:53 - AsmackTest] Dx bad class file magic (cafebabe) or version (0033.0000) ...while parsing com/novell/sasl/client/DigestChallenge.class ...while processing com/novell/sasl/client/DigestChallenge.class [2014-06-30 08:47:53 - AsmackTest] Dx
Seems reasonable that if I can get rid of warnings the code will work. In the log there is a suggestion to build the class from source. Unfortunately I am unable to build the asmack code: Cannot build asmack. So I am in limbo ..Where do I begun to troubleshoot?
Asmack version: asmack-android-8-4.0.0.jar
Stacktrace:
06-30 15:34:33.609: E/AndroidRuntime(25444): FATAL EXCEPTION: main 06-30 15:34:33.609: E/AndroidRuntime(25444): Process: com.example.asmacktest, PID: 25444 06-30 15:34:33.609: E/AndroidRuntime(25444): java.lang.NoClassDefFoundError: org.jivesoftware.smack.SmackAndroid 06-30 15:34:33.609: E/AndroidRuntime(25444): at com.example.asmacktest.MainActivity.onCreate(MainActivity.java:31) 06-30 15:34:33.609: E/AndroidRuntime(25444): at android.app.Activity.performCreate(Activity.java:5248) 06-30 15:34:33.609: E/AndroidRuntime(25444): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110) 06-30 15:34:33.609: E/AndroidRuntime(25444): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2173) 06-30 15:34:33.609: E/AndroidRuntime(25444): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2269) 06-30 15:34:33.609: E/AndroidRuntime(25444): at android.app.ActivityThread.access$800(ActivityThread.java:139) 06-30 15:34:33.609: E/AndroidRuntime(25444): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210) 06-30 15:34:33.609: E/AndroidRuntime(25444): at android.os.Handler.dispatchMessage(Handler.java:102) 06-30 15:34:33.609: E/AndroidRuntime(25444): at android.os.Looper.loop(Looper.java:136) 06-30 15:34:33.609: E/AndroidRuntime(25444): at android.app.ActivityThread.main(ActivityThread.java:5102) 06-30 15:34:33.609: E/AndroidRuntime(25444): at java.lang.reflect.Method.invokeNative(Native Method) 06-30 15:34:33.609: E/AndroidRuntime(25444): at java.lang.reflect.Method.invoke(Method.java:515) 06-30 15:34:33.609: E/AndroidRuntime(25444): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) 06-30 15:34:33.609: E/AndroidRuntime(25444): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) 06-30 15:34:33.609: E/AndroidRuntime(25444): at dalvik.system.NativeStart.main(Native Method) 06-30 15:34:43.501: E/WindowManager(1001): Starting window AppWindowToken{440206f0 token=Token{4373dbe0 ActivityRecord{4373da80 u0 com.example.asmacktest/.MainActivity t310}}} timed out