0

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?

Community
  • 1
  • 1
Ashish Singh
  • 135
  • 1
  • 14
  • Try to look at http://stackoverflow.com/questions/34413/why-am-i-getting-a-noclassdeffounderror-in-java – S K Oct 09 '15 at 15:19
  • Its odd if you are explicietly using 'android.text.ClipboardManager' and it says class not found for 'android.content.ClipboardManager'. However I would decompile your classes.dex to see what the actual complied byte code is using. Just to rule out that the your compiled code is still referring to 'android.content' You can quickly do this with dex2jar (https://github.com/pxb1988/dex2jar/releases) and jd-gui (http://jd.benow.ca/). – Damien O'Reilly Oct 09 '15 at 15:26
  • Thank you for replying. @DamienO'Reilly I decompiled the code and sure enough there is import android.content.ClipData; import android.content.ClipboardManager; code in MainActivity.java. That code isn't there in my original file. I already remove it. How do I remove it permanently? – Ashish Singh Oct 09 '15 at 16:12
  • Sounds like your changes aren't taking effect and its an old build on your phone/emulator. Can you make some other change and see if that takes effect? Like showing a Toast or something. – Damien O'Reilly Oct 12 '15 at 08:43

0 Answers0