我无法导入
RequiresApi
。
错误:
Import android.support.annotation.RequiresApi; - (Can not resolve symbol 'RequiresApi')
在Android Image Cropper项目中使用,部分代码:
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public void start(@NonNull Context context, @NonNull android.app.Fragment fragment) {
fragment.startActivityForResult(getIntent(context), CROP_IMAGE_ACTIVITY_REQUEST_CODE);
}
minSdkVersion 17
我的毕业生:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
useLibrary 'org.apache.http.legacy'
lintOptions {
checkReleaseBuilds false
}
defaultConfig {
applicationId "com.myapp.myapp"
minSdkVersion 20
targetSdkVersion 23
versionCode 18
versionName "1.998"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/universal-image-loader-1.9.5.jar')
compile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.google.android.gms:play-services-ads:8.3.0'
compile 'com.google.android.gms:play-services-location:8.3.0'
compile 'com.google.code.gson:gson:2.3'
}
这很可能是由于缺少注释依赖性。
添加到您的
build.gradle
并同步:
dependencies {
implementation("androidx.annotation:annotation:1.7.1")
}