AiVision
AiVision

Reputation: 4233

java.lang.NoClassDefFoundError: android.media.projection.MediaProjectionManager

MediaProjectionManager manager =
        (MediaProjectionManager) activity.getSystemService(MEDIA_PROJECTION_SERVICE);
    Intent intent = manager.createScreenCaptureIntent();
    activity.startActivityForResult(intent, CREATE_SCREEN_CAPTURE);

this is my code and i am getting the following error

03-22 07:52:02.271 14831-14831/? E/dalvikvm: Could not find class 'android.media.projection.MediaProjectionManager', referenced from method com.zennaxx.marshmallowscreenrecorder.CaptureHelper.fireScreenCaptureIntent
03-22 07:52:02.371 14831-14831/? E/AndroidRuntime: FATAL EXCEPTION: main
03-22 07:52:02.371 14831-14831/? E/AndroidRuntime: Process: com.zennaxx.marshmallowscreenrecorder, PID: 14831
03-22 07:52:02.371 14831-14831/? E/AndroidRuntime: java.lang.NoClassDefFoundError: android.media.projection.MediaProjectionManager
03-22 07:52:02.371 14831-14831/? E/AndroidRuntime:     at com.zennaxx.marshmallowscreenrecorder.CaptureHelper.fireScreenCaptureIntent(CaptureHelper.java:22)
03-22 07:52:02.371 14831-14831/? E/AndroidRuntime:     at com.zennaxx.marshmallowscreenrecorder.ScreenRecorderActivity.onLaunchClicked(ScreenRecorderActivity.java:136)
03-22 07:52:02.371 14831-14831/? E/AndroidRuntime:     at com.zennaxx.marshmallowscreenrecorder.ScreenRecorderActivity$$ViewBinder$6.doClick(ScreenRecorderActivity$$ViewBinder.java:80)
03-22 07:52:02.371 14831-14831/? E/AndroidRuntime:     at butterknife.internal.DebouncingOnClickListener.onClick(DebouncingOnClickListener.java:22)
03-22 07:52:02.371 14831-14831/? E/AndroidRuntime:     at android.view.View.performClick(View.java:4569)
03-22 07:52:02.371 14831-14831/? E/AndroidRuntime:     at android.view.View$PerformClick.run(View.java:18570)
03-22 07:52:02.371 14831-14831/? E/AndroidRuntime:     at android.os.Handler.handleCallback(Handler.java:733)
03-22 07:52:02.371 14831-14831/? E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:95)
03-22 07:52:02.371 14831-14831/? E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:212)
03-22 07:52:02.371 14831-14831/? E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5135)
03-22 07:52:02.371 14831-14831/? E/AndroidRuntime:     at java.lang.reflect.Method.invokeNative(Native Method)
03-22 07:52:02.371 14831-14831/? E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:515)
03-22 07:52:02.371 14831-14831/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
03-22 07:52:02.371 14831-14831/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
03-22 07:52:02.371 14831-14831/? E/AndroidRuntime:     at dalvik.system.NativeStart.main(Native Method)

Upvotes: 1

Views: 1497

Answers (1)

RafToTheK
RafToTheK

Reputation: 86

This exception is typical (i.e. common programming mistake), if you start the app on a device with an API level that is too low. The class needs API Level 21, so you should set min API Level to 21 in your build.gradle or do some exception handling / branching

Upvotes: 3

Related Questions