Context context;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
You can set target android of your project to android 6.0 or higher. Then add android-support-v4.jar
This issue occurs because the support library is out of date.
If you're using Eclipse, I've found the most simple solution is to right-click the project and go to:
Android Tools > Add support library...
If this doesn't resolve the issue, you probably need to update the SDK first:
Window > Android SDK Manager > Install Updates
The support library will be added/updated and will no longer show this error.
ContextCompat.checkSelfPermission()
requires support library in version 23 or higher.
Add in dependencies
block in lower-level build.gradle
:
compile 'com.android.support:appcompat-v7:23.1.1'
If you have previous version here (which you probably have), you should replace lane with provided by me.