构建失败并显示错误:unable to find symbol method checkSelfPermission
虽然我已经添加了支持库。
它在构建之后会出错,但在Android Studio中没有用红色标记,或者标记为缺失,仍然在构建之后,会收到此方法丢失错误。
摇篮
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
}
}
apply plugin: 'com.android.application'
dependencies {
compile fileTree(
: '*.jar', dir: 'libs')
compile project(':AndroidLicensingLibary')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.0'
compile 'com.android.support:support-v13:23.0.+'
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
}
主要活动(在setContent之后创建内部)
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.READ_CONTACTS)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.READ_CONTACTS},
1003);
}
MESSAGE
/Users/TechwinLabsAndroid/Documents/Gurvinder Bawa/Projects/redd/src/com/easymitigationinsppro/LoaderActivity.java
Error:(49, 20) error: cannot find symbol method checkSelfPermission(LoaderActivity,String)
Error:(53, 19) error: cannot find symbol method requestPermissions(LoaderActivity,String[],int)
/Users/TechwinLabsAndroid/Documents/Gurvinder Bawa/Projects/redd/src/com/easymitigationinsppro/wizard/fragment/PhotoFra gment.java
Error:(294, 19) error: cannot find symbol method requestPermissions(FragmentActivity,String[],int)
Error:(304, 8) error: cannot find symbol method onRequestPermissionsResult(int,String[],int[])
Error:Execution failed for task ':compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Information:BUILD FAILED
Information:Total time: 5.712 secs