以前我在 MacOs M1 上安装了 Homebrew rosetta 版本,现在我看到 HomeBrew 有原生版本,那么我如何在 rosetta 上删除 HomeBrew 并安装原生版本。请帮我解决这个问题,谢谢
我试图在文件系统上创建一个文件,但仍然遇到此异常:
private fun getTempFolder(): File {
val directoryFolder =
File(Environment.getExternalStorageDirectory(), "sample-take-image")
directoryFolder.mkdirs()
return directoryFolder
}
private fun getTempFile(): File {
val timeStamp = SimpleDateFormat("yyyyMMdd_HHMMss", Locale.getDefault()).format(Date())
return File(
getTempFolder().absolutePath,
"image".plus(Calendar.getInstance().timeInMillis).plus(timeStamp).plus(".jpg")
)
}
private fun saveImageToFile(bitmap: Bitmap? = null): String? {
return try {
val file = getTempFile()
Timber.e("Path: + : ${file.absolutePath}")
file.createNewFile()
val fOut = FileOutputStream(file)
bitmap?.apply {
this.compress(Bitmap.CompressFormat.JPEG, 100, fOut)
}
fOut.flush()
fOut.close()
file?.absolutePath.getDefault()
} catch (e: Exception) {
e.printStackTrace()
""
}
}
Run Code Online (Sandbox Code Playgroud)
尽管我在拍照后得到了链接:
:/存储/模拟/0/sample-take-image/image162064003789420210510_160517.jpg
那么有人可以告诉我为什么在这种情况下我无法创建文件。我目前 使用的是Android 11
**编译SdkVersion …