0

I am trying to use org.apache.commons.collections.CollectionUtils in Android. The sample is below

import java.util.ArrayList;

import org.apache.commons.collections.CollectionUtils;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class CheckCommonsActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    String email1 = "[email protected]";
    String email2 = "[email protected]";
    String email3 = "[email protected]";
    String email4 = null;       

    ArrayList<String> emailList1 = new ArrayList<String>();
    emailList1.add(email4);
    emailList1.add(email1);
    emailList1.add(email2);
    emailList1.add(email3);

    ArrayList<String> emailList2 = new ArrayList<String>();
    emailList2.add(email3);
    emailList2.add(email2);
    emailList2.add(email1);

    boolean isEqual = CollectionUtils.isEqualCollection(emailList1,
 emailList2);
    TextView text = (TextView) findViewById(R.id.text);
    text.setText(String.valueOf(isEqual));
   }
 }

I have imported commons-collections-3.2.1.jar to Build Path of Android Project, but I am getting error java.lang.NoClassDefFoundError: org.apache.commons.collections.CollectionUtils at runtime.

Edit1

Android Project Artifact

Thanks

2
  • @st0le Cleaning project does not help. Commented Apr 10, 2012 at 13:57
  • What is there in Android Dependencies? Commented Apr 10, 2012 at 14:16

1 Answer 1

6

You have to put the library in /libs (not /lib) folder of your android project

Edit: I was assuming that you put it in /lib folder because this is a common failure. In your added screenshot can be seen that you included the lib as external jar. Anyway..whether you put it in /lib or as external jar the solution is the same: create /libs folder and put the lib there

Sign up to request clarification or add additional context in comments.

2 Comments

Appended a image showing the android project. I could not find the /libs or /lib folder.
You have to create the /libs folder in your android project. Put your lib in there. In Eclipse select build path and "Add Jars..." (not "External Jars")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.