ClipBoardManager Android ... NoClassdefFoundException

I am developing an Android application and copying text (from the listView element) to the clipboard to paste it into editText.

So the copy function looks like this:

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

However, the exception is thrown on the first line:

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

I searched for it, but I did not find working answers.

thanks for answers

+3
source share
1 answer

Check out the ClipboardManager package.

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

android.content.ClipboardManager is only available at API level 11 and above. I assume the cause of this error.

So you use your code on old phones, you should use android.text.ClipboardManager

+3
source

All Articles