David
David

Reputation: 37536

Android Studio isn't recognizing the checkSelfPermission

Is it possible to run Google Sample - RuntimePermissionsBasic

On devices with OS less than MNC (Android M)?

This project comes with:

compileSdkVersion "android-MNC"
targetSdkVersion "MNC"

So far so good, running it on less than M OS will get:

INSTALL_FAILED_OLDER_SDK

But when I changed it to:

compileSdkVersion 22
targetSdkVersion "MNC"

The Android Studio isn't recognizing the checkSelfPermission (...) method

Upvotes: 1

Views: 4565

Answers (2)

Alexiscanny
Alexiscanny

Reputation: 579

Try to add ContextCompat.checkSelfPermission() instead just checkSelfPermission...for me it works...

Upvotes: 5

CommonsWare
CommonsWare

Reputation: 1006674

So far so good, running it on less than M OS will get: INSTALL_FAILED_OLDER_SDK

That is because setting compileSdkVersion to android-MNC forces the minSdkVersion to MNC by default. There are recipes for changing that behavior.

But when I changed it to... The Android Studio isn't recognizing the checkSelfPermission (...) method

checkSelfPermission() was introduced in the M Developer Preview and does not exist on older versions of Android.

Upvotes: 2

Related Questions