Q:

Android drag and drop error

I am following a step by step guide to mastering drag and drop and am frustrated that step 1 is giving me an error. I am getting a NoClassDefFoundError. Can anyone see what I am doing wrong.
It is really annoying that I copied the guys code exactly and it doesn't work.
I put a star on the line that it is crashing on. The one that defines clipdata.

07-01 14:37:47.544: E/AndroidRuntime(17055): FATAL EXCEPTION: main
  07-01 14:37:47.544: E/AndroidRuntime(17055):
  java.lang.NoClassDefFoundError: android.content.ClipData 07-01
  14:37:47.544: E/AndroidRuntime(17055):    at
  com.codelikely.tester.TestApplicationActivity.onTouch(TestApplicationActivity.java:29)
  07-01 14:37:47.544: E/AndroidRuntime(17055):  at
  android.view.View.dispatchTouchEvent(View.java:4020) 07-01
  14:37:47.544: E/AndroidRuntime(17055):    at
  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:869) 07-01
  14:37:47.544: E/AndroidRuntime(17055):    at
  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:869) 07-01
  14:37:47.544: E/AndroidRuntime(17055):    at
  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:869) 07-01
  14:37:47.544: E/AndroidRuntime(17055):    at
  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:869) 07-01
  14:37:47.544: E/AndroidRuntime(17055):    at
  com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1746)
  07-01 14:37:47.544: E/AndroidRuntime(17055):  at
  com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1152)
  07-01 14:37:47.544: E/AndroidRuntime(17055):  at
  android.app.Activity.dispatchTouchEvent(Activity.java:2102) 07-01
  14:37:47.544: E/AndroidRuntime(17055):    at
  com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1730)
  07-01 14:37:47.544: E/AndroidRuntime(17055):  at
  android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2268) 07-01
  14:37:47.544: E/AndroidRuntime(17055):    at
  android.view.ViewRoot.handleMessage(ViewRoot.java:1921) 07-01
  14:37:47.544: E/AndroidRuntime(17055):    at
  android.os.Handler.dispatchMessage(Handler.java:99) 07-01
  14:37:47.544: E/AndroidRuntime(17055):    at
  android.os.Looper.loop(Looper.java:130) 07-01 14:37:47.544:
  E/AndroidRuntime(17055):  at
  android.app.ActivityThread.main(ActivityThread.java:3691) 07-01
  14:37:47.544: E/AndroidRuntime(17055):    at
  java.lang.reflect.Method.invokeNative(Native Method) 07-01
  14:37:47.544: E/AndroidRuntime(17055):    at
  java.lang.reflect.Method.invoke(Method.java:507) 07-01 14:37:47.544:
  E/AndroidRuntime(17055):  at
  com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
  07-01 14:37:47.544: E/AndroidRuntime(17055):  at
  com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665) 07-01
  14:37:47.544: E/AndroidRuntime(17055):    at
  dalvik.system.NativeStart.main(Native Method)

@Override
    public boolean onTouch(View view, MotionEvent motionEvent) {
        if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
            *ClipData clipData = ClipData.newPlainText("", "");*
            View.DragShadowBuilder dsb = new View.DragShadowBuilder(view);
            view.startDrag(clipData, dsb, view, 0);
            view.setVisibility(View.INVISIBLE);
            return true;
        } else {
            return false;
        }
    }

A:

Your app cannot find the ClipData class. ClipDate is only available from API level 11 and above. You're running on 2.3, which is API level 9. As you are building against a higher API, you will not get an error at compile time. To make sure you aren't using any other classes added later on, try setting your project to build with 2.3, or whatever OS is your minimum target.

