I continue to receive this error message in the error reporting done by users for my Android app:
java.lang.NoClassDefFoundError: android.content.ClipboardManager
at com.nepali_unicode.nepalityping.MainActivity.onCreate(Unknown Source)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1630)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1682)
at android.app.ActivityThread.access$1500(ActivityThread.java:121)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:940)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3714)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:853)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:611)
at dalvik.system.NativeStart.main(Native Method)
I just want a simple edittext field and a button which can be pressed to copy the content of the edidtext. Basicaly what I want to do is support older devices going as far as Android 2.3.3 or even Android 2.2. I have asked a question here already about the same problem. Tried the solution:
if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.HONEYCOMB) {
// do the newer API
}
else {
// do the older API
}
It did work when I tested it Android Virtual Devices emulator but my users who updated to the new app still reported the same error even though they updated to the new version.
I tried a multitude of other solutions found all over stackoverflow but still I keep getting error reports.
Here's the code that I am currently using:
buttonCopy.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
copyText = editText.getText().toString();
@SuppressWarnings("deprecation")
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
clipboard.setText(copyText);
}
});
The popular device that report the error are: Galaxy Y (GT-S5360)
The Android version that reports the error: Android 2.3.3 - 2.3.7
As far as I know the error is related to android.content.ClipboardManager
I use android.text.ClipboardManager as seen in the code above.
Why am I still getting the android.content.ClipboardManager error?