NoClassDefFoundError: org.apache.xmlrpc.client.XmlRpcClient

3k views Asked by At

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

3

There are 3 answers

0
Yenthe On BEST ANSWER

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.

2
Siddharth_Vyas On

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.

0
Raouf Rhimi On

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.