最近我的Android Studio更新到2.3.2,自更新以来,我无法将项目运行到手机上。首先,它会在gradle构建期间显示没有错误。但是当你在手机上运行它时会出现以下错误。
Error:(203, 43) error: cannot find symbol method requestPermissions(DoctorEditProfileActivity,String[],int)
Error:(213, 43) error: cannot find symbol method requestPermissions(DoctorEditProfileActivity,String[],int)
C:\Users\Narendran\Desktop\Appsilon\Floater\CloudTest\app\src\main\java\com\dovo\health\appsilonapp\DoctorHomeActivity.java
Error:(133, 27) error: cannot find symbol method requestPermissions(DoctorHomeActivity,String[],int)
Error:(139, 27) error: cannot find symbol method requestPermissions(DoctorHomeActivity,String[],int)
Error:(670, 35) error: cannot find symbol method getActionView(MenuItem)
C:\Users\Narendran\Desktop\Appsilon\Floater\CloudTest\app\src\main\java\com\dovo\health\appsilonapp\DoctorReferDoctorActivity.java
Error:(89, 27) error: cannot find symbol method requestPermissions(DoctorReferDoctorActivity,String[],int)
Error:(272, 27) error: cannot find symbol method requestPermissions(DoctorReferDoctorActivity,String[],int)
C:\Users\Narendran\Desktop\Appsilon\Floater\CloudTest\app\src\main\java\com\dovo\health\appsilonapp\DoctorSetupProfileActivity.java
Error:(238, 43) error: cannot find symbol method requestPermissions(DoctorSetupProfileActivity,String[],int)
Error:(248, 43) error: cannot find symbol method requestPermissions(DoctorSetupProfileActivity,String[],int)
C:\Users\Narendran\Desktop\Appsilon\Floater\CloudTest\app\src\main\java\com\dovo\health\appsilonapp\GetPermissionActivity.java
Error:(37, 27) error: cannot find symbol method requestPermissions(GetPermissionActivity,String[],int)
Error:(48, 27) error: cannot find symbol method requestPermissions(GetPermissionActivity,String[],int)
Error:(59, 27) error: cannot find symbol method requestPermissions(GetPermissionActivity,String[],int)
C:\Users\Narendran\Desktop\Appsilon\Floater\CloudTest\app\src\main\java\com\dovo\health\appsilonapp\MyGcmListenerService.java
Error:(54, 59) error: cannot access AbstractSafeParcelable
class file for com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable not found
Error:(606, 49) error: cannot find symbol class BigTextStyle
Error:(613, 65) error: cannot find symbol method build()
Error:(628, 49) error: cannot find symbol class BigTextStyle
Error:(635, 65) error: cannot find symbol method build()
C:\Users\Narendran\Desktop\Appsilon\Floater\CloudTest\app\src\main\java\com\dovo\health\appsilonapp\PatientEditProfileActivity.java
Error:(245, 43) error: cannot find symbol method requestPermissions(PatientEditProfileActivity,String[],int)
Error:(256, 43) error: cannot find symbol method requestPermissions(PatientEditProfileActivity,String[],int)
C:\Users\Narendran\Desktop\Appsilon\Floater\CloudTest\app\src\main\java\com\dovo\health\appsilonapp\PatientSendReportActivity.java
Error:(97, 43) error: cannot find symbol method requestPermissions(PatientSendReportActivity,String[],int)
Error:(107, 43) error: cannot find symbol method requestPermissions(PatientSendReportActivity,String[],int)
C:\Users\Narendran\Desktop\Appsilon\Floater\CloudTest\app\src\main\java\com\dovo\health\appsilonapp\PatientSetupProfileActivity.java
Error:(403, 43) error: cannot find symbol method requestPermissions(PatientSetupProfileActivity,String[],int)
Error:(414, 43) error: cannot find symbol method requestPermissions(PatientSetupProfileActivity,String[],int)
C:\Users\Narendran\Desktop\Appsilon\Floater\CloudTest\app\src\main\java\com\dovo\health\appsilonapp\SplashScreenActivity.java
Error:(207, 27) error: cannot find symbol method requestPermissions(SplashScreenActivity,String[],int)
Error:(220, 27) error: cannot find symbol method requestPermissions(SplashScreenActivity,String[],int)
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Information:BUILD FAILED
Information:Total time: 14.028 secs
Information:26 errors
Information:1 warning
Information:See complete output in console
无法找到ActivityCompat中的方法requestPermission。我尝试点击ActivityCompat来检查源代码,但它没有requestPermission方法。实际上,ActivityCompat中只有两种方法。
我在这里与所有依赖项共享我的应用程序gradle。
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/ASL2.0'
}
defaultConfig {
applicationId 'com.dovo.health.xxxxx'
minSdkVersion 15
targetSdkVersion 25
versionCode 39
versionName '1.2.3'
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(path: ':DoctorBackend', configuration: 'android-endpoints')
//Sinch
compile files('libs/fluent-hc-4.5.2.jar')
compile files('libs/jna-platform-4.1.0.jar')
compile files('libs/jna-4.1.0.jar')
compile files('libs/commons-codec-1.9.jar')
compile files('libs/httpmime-4.5.2.jar')
compile files('libs/httpclient-win-4.5.2.jar')
compile files('libs/commons-logging-1.2.jar')
compile files('libs/httpclient-cache-4.5.2.jar')
compile files('libs/httpclient-4.5.2.jar')
compile files('libs/httpcore-4.4.4.jar')
compile 'com.android.support:support-v4:25.2.0'
compile 'com.google.android.gms:play-services-base:10.2.6'
compile 'com.citruspay.sdk:payment-sdk:4.0.1'
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'com.android.support:recyclerview-v7:25.2.0'
compile 'com.google.firebase:firebase-messaging:9.6.1'
compile 'com.heinrichreimersoftware:material-intro:1.4'
compile 'org.jsoup:jsoup:1.9.2'
compile 'com.google.apis:google-api-services-storage:v1-rev107-1.22.0'
compile 'com.wu-man:android-oauth-client:0.0.3'
compile 'com.google.appengine:appengine-api-1.0-sdk:1.9.38'
compile 'com.google.android.gms:play-services-maps:10.2.6'
compile 'com.google.android.gms:play-services-location:10.2.6'
compile('com.google.api-client:google-api-client:1.19.0') {
exclude(group: 'com.google.guava', module: 'guava-jdk5')
}
}
apply plugin: 'com.google.gms.google-services'
这是给出错误的requestPermission的用法。这在一个Activity而不是一个片段中调用。
if (ContextCompat.checkSelfPermission(getBaseContext(),
android.Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,
new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE,
android.Manifest.permission.WRITE_EXTERNAL_STORAGE}, GALLERY_ACTIVITY_CODE);
} else {
chooseGalleryImage();
}