Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ClipBoardManager Android .... NoClassdefFoundException

I'm developping an android application, and a need to copy text (from listView item) to the clipboard in order to paste it in an editText.

So copy function looks like :

 ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
 clipboard.setText("String to copy");

However, an exception is fired on the first line :

04-12 15:08:59.101:
E/AndroidRuntime(25406): java.lang.NoClassDefFoundError: android.content.ClipboardManager

I've googled it, but i found no working answers.

Thanks for replies

like image 728
user988168 Avatar asked Feb 26 '26 14:02

user988168


1 Answers

Check the package of ClipboardManager.

One is from android.text package, and the other is from android.content package.

android.content.ClipboardManager is only available on API level 11 and up. I am guessing thats the reason for this error.

So, you for running your code on older phones, you should use android.text.ClipboardManager

like image 188
Kumar Bibek Avatar answered Feb 28 '26 04:02

Kumar Bibek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!