该错误是由于使用了Apache POI库的某些方法,而这些方法只支持Android O---------即API级别26及以上。因此,可以通过将minSdkVersion和targetSdkVersion设置为26或更高来解决此问题。如果您的应用程序需要支持旧版Android,则应使用其他库,或检查是否有其他版本的Apache POI可用。以下是build.gradle文件中的示例配置:
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 26
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}