Reputation: 31
I am trying to make an app for screenshot. I've found there are several guides for using MediaProjectionManager
for that purpose.
This is one of them.
http://www.truiton.com/2015/05/capture-record-android-screen-using-mediaprojection-apis/
I copied the source exactly but the Android studio just can't handle the MediaProjectionManager
.
These are the build error messages.
Error:(23, 32) error: package android.media.projection does not exist
Error:(24, 32) error: package android.media.projection does not exist
Error:(32, 13) error: cannot find symbol class MediaProjectionManager
Error:(35, 13) error: cannot find symbol class MediaProjection
Error:(171, 66) error: package MediaProjection does not exist
And these are the lines that are causing the error.
import android.media.projection.MediaProjection;
import android.media.projection.MediaProjectionManager;
I'm sure these class paths for MediaProjection
and MediaProjectionManager
are correct. A little help please.
Upvotes: 0
Views: 771
Reputation: 73
MediaProjection is added in API level 21 (Android 5.0). The "compileSdkVersion" of your Module needs to >= 21. e.g
android {
compileSdkVersion 26
...
defaultConfig {
minSdkVersion 21
...
}
}
Upvotes: 0