JAVAlang.NoSuchMethodError:安卓。操作系统。环境isExternalStorageRemovable
我正在尝试填充内存。但我的应用程序每次运行都会崩溃
我的logcat错误是:
java.lang.NoSuchMethodError: 安卓.os.Environment.isExternalStorageRemovable
at com.symbol.fillexternalmemory.MainActivity.getExternalSdCardSize(MainActivity.java:175)
at com.symbol.fillexternalmemory.MainActivity.onCreate(MainActivity.java:44)
我的主要活动。java是:
protected static Long getExternalSdCardSize() {
File storage = new File("/storage");
String external_storage_path = "";
Long size = null;
if (storage.exists()) {
File[] files = storage.listFiles();
for (File file : files) {
if (file.exists()) {
try {
if (Environment.isExternalStorageRemovable(file)) {
// storage is removable
external_storage_path = file.getAbsolutePath();
break;
}
} catch (Exception e) {
Log.e("TAG", e.toString());
}
}
}
}
if (!external_storage_path.isEmpty()) {
File external_storage = new File(external_storage_path);
if (external_storage.exists()) {
size = totalSize(external_storage);
}
}
return size;
}
还有我的身材。gradle文件是:
安卓 {
compileSdkVersion 23
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.symbol.fillexternalmemory"
minSdkVersion 22
targetSdkVersion 23
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-安卓.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
}
dependencies {
compile 'com.安卓.support:support-v4:23.4.0'
}
有人能告诉我为什么每次应用程序都会崩溃吗?我已经参考了以前对类似问题的答案,但找不到一个合适的解决方案来帮助你
共 (0) 个答案