0

I've started developing with XML-RPC in Android but since I've added the JAR files I keep getting this error when I click on my button:

java.lang.NoClassDefFoundError: org.apache.xmlrpc.client.XmlRpcClient

I always get it when I click on the button with this code:

public void addListenerOnButton() {

    button = (Button) findViewById(R.id.button1);

    button.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            final String url = "http://www.myUrl.com:8069/";
            final String db = "dbname";
            final String username = "username";
            final String password = "password";

            final XmlRpcClient client = new XmlRpcClient();

            final XmlRpcClientConfigImpl start_config = new XmlRpcClientConfigImpl();
            /*Toast.makeText(MainActivity.this, 
                    "Your Message", Toast.LENGTH_LONG).show();*/
        }
    });
}

I've added the external JAR files org-apache-xmlrpc, xmlrpc-3.0a1 and xmlrpc-client as you can see here:

And this is the problem that keeps popping up:

Can anybody explain me what I'm doing wrong and how I can fix this please? I'm really stuck on this one.

Thanks Yenthe

Yenthe
  • 2,313
  • 5
  • 26
  • 46
  • Just add your libraries under "libs" folder.You have added them under "Referenced libraries". – Siddharth_Vyas Dec 01 '14 at 13:41
  • So I should add them under the libs folder and remove all external JAR's then? – Yenthe Dec 01 '14 at 13:46
  • Yes, basically when you add external jar files you add them under libs folder. – Siddharth_Vyas Dec 01 '14 at 13:46
  • I've removed the external JAR's and added them directly under libs. This now looks like this: http://i.imgur.com/FjqoLgw.png When I run it I get the following error: [2014-12-01 14:47:37 - Dex Loader] Unable to execute dex: Multiple dex files define Lorg/apache/xmlrpc/client/AsyncCallback; [2014-12-01 14:47:37 - Odoo] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lorg/apache/xmlrpc/client/AsyncCallback; – Yenthe Dec 01 '14 at 13:48
  • Error of "Unable to execute dex: Multiple dex files " is because you now have two copies of same jar files.You need to remove the previous jar files from Build path and after that add jar files again. – Siddharth_Vyas Dec 01 '14 at 13:50
  • @SiddharthVyas I've already removed them there? As you can see here: http://i.imgur.com/lKqRTh2.png so I'm not sure what is wrong.. – Yenthe Dec 01 '14 at 13:52
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/65965/discussion-between-siddharth-vyas-and-yenthe). – Siddharth_Vyas Dec 01 '14 at 13:52

3 Answers3

1

Go to Project/Properties/Java Build Path/Order and Export -- Make sure there's a check in front of Android Dependencies and the support library, if you use it.

Mark all checkboxes and Click on Apply and clean the project.

Hope this helps.

Siddharth_Vyas
  • 9,972
  • 10
  • 39
  • 69
0

It turned out that I had to include another JAR file for the XML-RPC. You can download all these JAR files here: http://archive.eu.apache.org/dist/ws/xmlrpc/apache-xmlrpc-current-bin.zip

After downloading all these JAR files you should all place them under libs and then clean your project. Then it is solved.

Yenthe
  • 2,313
  • 5
  • 26
  • 46
0

I faced the same problem when i was working with WSO2 micro-integrator when initializing the class mediator that implements "XmlRpcClientConfig" interface.I figured out that i should place the jar files for apache-xmlrpc client to the libs folder in WSO2 Micro integrator and it works fine.