Ошибка no such file or directory android

Replace:

Environment.getExternalStoragePublicDirectory(
                Environment.DIRECTORY_PICTURES)

With:

private File createImageFile() throws IOException {
        // Create an image file name

make sure you call:

mkdirs() // and not mkdir()

Here’s the code that should work for you:

        String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
        String imageFileName = "JPEG_" + timeStamp + "_";
        File storageDir = new File(Environment.getExternalStorageDirectory().toString(), "whatever_directory_existing_or_not/sub_dir_if_needed/");
        storageDir.mkdirs(); // make sure you call mkdirs() and not mkdir()
        File image = File.createTempFile(
                imageFileName,  // prefix
                ".jpg",         // suffix
                storageDir      // directory
        );

        // Save a file: path for use with ACTION_VIEW intents

        mCurrentPhotoPath = "file:" + image.getAbsolutePath();
        Log.e("our file", image.toString());
        return image;
    }

I had a bad experience following the example given in Android Studio Documentation and I found out that there are many others experiencing the same about this particular topic here in stackoverflow, that is because even if we set

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

the problem persists in some devices.

My experience was that the example worked when I tried it in debug mode, after that 3 more tests it so happened that my SD suddenly was corrupted, but I don’t think it has to do with their example (funny). I bought a new SD card and tried it again, only to realize that still both release and debug mode did the same error log: directory does not exist ENOENT. Finally, I had to create the directories myself whick will contain the captured pictures from my phone’s camera. And I was right, it works just perfect.

I hope this helps you and others out there searching for answers.

In this guide, we will show you different methods to fix the Fastboot FAILED (remote: No such file or directory) error. The ADB and Fastboot Commands are the unsung heroes of custom development. They are among the most useful as well as important tools that we could have in our arsenal.

Right from the basic tasks of booting the device to Fastboot or Recovery, to the technical ones involving the flashing of custom binaries, there’s a lot that these commands are capable of doing. However, at the same time, they aren’t free from their fair share of issues either. There are quite a few errors that bug this ecosystem from time to time. In this regard, the inability to find the required directory seems to be among the most common issues.

This happens when you execute a command in the CMD or PowerShell window but the latter isn’t able to read the file associated with that command. Now there could be quite a few reasons for the same. And this guide shall make you aware of all of them as well as their associated fixes. So without further ado, let’s check out the various methods to fix the Fastboot FAILED (remote: No such file or directory) error.


  • How to Fix FAILED (remote: Command not allowed)
  • How to Extract payload.bin and get stock boot image file
  • Fix FAILED (remote: Partition flashing is not allowed)

fix Fastboot FAILED (remote No such file or directory) error

There isn’t any universal fix as such. You will have to try out each of the below-mentioned methods until one of them spells out success for you.

Fix 1: Check File Name

fastboot boot twrp fix FAILED (remote No such file or directory)

To begin with, make sure that the file name that you have entered inside the Command Prompt or PowerShell window exactly matches the name of that file. The upper and lower cases, hyphens, spaces, etc all should match.

Fix 2: Verify File Location

fix Fastboot FAILED (remote: No such file or directory) errorNext up, the file that you are planning to flash should be placed inside the platform-tools folder. And the CMD window should also be opened inside the same folder. To do so, head over to that platform-tools folder address bar, type in CMD and hit Enter. This shall launch the Command Prompt window with the ADB directory automatically picked up. Now try executing the desired command and see if it fixes the Fastboot FAILED (remote: No such file or directory) error.

Fix 3: Install Fastboot Drivers

fix Fastboot FAILED (remote: No such file or directory) error

In most cases, the SDK Platform Tools are more than enough for your Android device. However, sometimes you might also have to install the standalone Fastboot Drivers. To do so, grab hold of the latest Google’s Android Bootloader Interface Drivers and install it onto your PC. The installation instructions are given in that linked guide itself, do refer to it. Once installed, verify whether the Fastboot FAILED (remote: No such file or directory) error has been fixed or not.

Fix 4: Use USB 2.0 Port

fix Fastboot FAILED (remote: No such file or directory) error

In some instances, the USB 3.0 Port might not be able to identify a device connected in Fastboot Mode. Therefore, you should connect the device in USB 2.0 Port. Along the same lines, you should only use the official USB cable that came shipped with your device. If you don’t have it, then use the official cable of any other Android device. But it should have came out of the box with a smartphone and shouldn’t be a standalone USB cable.

That’s it. These were the various methods to fix the Fastboot FAILED (remote: No such file or directory) error. We have shared four different workarounds in this regard. Do let us know in the comments section which one spelled out success for you.

About Chief Editor

Sadique Hassan

administrator

A technical geek by birth, he always has a keen interest in the Android platform right since the birth of the HTC Dream. The open-source environment always seems to intrigue him with the plethora of options available at his fingertips. “MBA by profession, blogger by choice!”

fastboot error when installing twrp

Sadique Hassan

administrator

A technical geek by birth, he always has a keen interest in the Android platform right since the birth of the HTC Dream. The open-source environment always seems to intrigue him with the plethora of options available at his fingertips. “MBA by profession, blogger by choice!”

Installing TWRP onto a smartphone or tablet typically requires you to use a Fastboot command to overwrite your current recovery system. Some people have trouble with the Command Prompt and in turn end up getting a cannot load twrp.img error, or being told there is no such file or directory. But there is a way to fix it.

The reason why someone is getting this specific error has to do with the last part of the Fastboot command. So, for example, a typical command to install a Custom Recovery (TWRP in this case) onto an Android device looks like this: fastboot flash recovery twrp.img. We can break this command down to see what it’s actually doing. . .

Fastboot – this initiates the Fastboot.exe file which is the file doing all of the work

Flash – this tells the Fastboot.exe file we want to install something onto the connected device

Recovery – this tells the Fastboot.exe file that when we install something, we’re installing it onto the recovery partition

TWRP.img – this tells the Fastboot.exe file what we want to install onto the connected device

So what the “cannot load ‘twrp.img’: No such file or directory” error is telling us is what it looked for the twrp.img file in the current directory (which should be where your ADB and Fastboot tools are installed) and couldn’t find it. There are a few ways this can happen but 9 times out of 10 it has to do with the file path of the twrp.img file.

Some people forget to rename the file to twrp.img. Others may forget to put it in the ADB and Fastboot tools folder. They may even have two different installs of ADB and Fastboot tools over the years. There are many reasons but we can eliminate any file path related issues by doing the following.

Time needed: 3 minutes.

  1. Drag and drop the twrp.img file into the Command Prompt instead of typing out the filename

    Watch the video below to show how it’s done.

I received a comment the other day from someone who was receiving this exact error. Again, the only reason why this error would come up is related to the file path of the twrp.img image. There are so many ways this can get mixed up when trying to execute that Fastboot command but the suggestion above should avoid all of that.

It can be a bit difficult to explain over text so you may want to see me do it via the video.

Instead of typing out that twrp.img part of the Fastboot command, we’re going to leave it open-ended right before the file. So instead of the typed out command being fastboot flash recovery twrp.img, we’re just going to type out “fastboot flash recovery “.

You’ll want to make note of the extra space I left after the word “recovery”.

That is very important because we need a space after the word recovery and before the file path of the twrp.img image. If not, we end up with a command that looks like fastboot flash recoveryE:ImagesXiaomiRedmi-Note-6-Protwrp.img. To the Fastboot.exe file, this command messes up the syntax.

Я сделал 2 ошибки:
1) выше апи 29 получать абсолютный путь нельзя (изменили из соображений безопасности) — поэтому выходила ошибка No such file or directory, нужно копировать файл в кеш папку приложения.
2) pdf файл нужно не только создать но и записать туда данные, а я только создал (и после того как исправил ошибку еще долго искал почему на сервер приходит пустой файл).

Итого решение выглядит так (основные шаги)

1) Запускаю окно выбора файла:

Intent

val pdfIntent = Intent(Intent.ACTION_GET_CONTENT)
pdfIntent.type = «application/pdf»
pdfIntent.addCategory(Intent.CATEGORY_OPENABLE)
startActivityForResult(pdfIntent, 12)

2) Переопределяю fun onActivityResult, в ней из полученной в ней data получаю uri и отправляю его сначала в функцию getDriveFilePath(uri)
val uri = data.data
Функция getDriveFilePath создает 2 File() и 2 stream и копирует данные по stream в файл в кеш директории (если не скопировать данные, а только создать файл, на сервер придет пустой файл, и еще важно копировать данные как для символьного файла, а не как для картинки, иначе тоже будет пустой файл).

Функция getDriveFilePath

val file = File(requireContext().getCacheDir(), name)
try {
val instream: InputStream = requireContext().getContentResolver().openInputStream(uri)!!
val output = FileOutputStream(file)
val buffer = ByteArray(1024)
var size: Int
while (instream.read(buffer).also { size = it } != -1) {
output.write(buffer, 0, size)
}
instream.close()
output.close()
} catch (e: IOException) {
Log.d(«TAG1», «e: ${e}»)
}

3) Отправляем полученный file в retrofit функцию, прикрепляем его к запросу и все.

file.asRequestBody("application/pdf".toMediaTypeOrNull())

Надеюсь это кому-то пригодится, потому что в полном виде для pdf я это нигде не нашел.

При попытке перепрошить Xiaomi Mi 5 на глобальную прошивку с помощью утилиты XiaoMiFlash.exe (из комплекта MIUI ROM Flashing Tool) в логах получаю ошибку:

fastboot: error: cannot load D:DriversXiaomi Mi5ROM: no such file or directory

Скриншот я не сделал, а повторять процесс прошивки не хочу, так что поверьте на слово :)
Не знаю, в чём именно накосячили китайские программисты, но утилита не видит файлы, если путь очень длинный. Скорее всего это проблема fastboot и именно её задействует MiFlash при прошивке. У меня путь к папке с образом для прошивки был такой:
D:DriversXiaomi Mi5ROMLineageOS18.12. MIUIgemini_global_images_V10.2.2.0.OAAMIXM_20190115.0000.00_8.0_global

Сначала я действительно хотел прошить LineageOS, поэтому прошил TWRP, потом прошил глобальную прошивку MIUI и только потом нужно было прошивать LineageOS, но мне понравилась MIUI 18.1, поэтому на этом этапе я и остановился.

Из-за того, что у меня оказалось достаточно большое количество вложенных папок, путь к нужным файлам оказался длинным.

Решение

Для решения проблемы достаточно было перенести папку с прошивкой куда-нибудь «поближе» к корню текущего диска. Например так:
D:gemini_global_images_V10.2.2.0.OAAMIXM_20190115.0000.00_8.0_global

В моём случае был действительно довольно длинный путь из-за имени папки. Так что можно было её переименовать например на gemini_global_image.

  • Об авторе
  • Недавние публикации

DenTNT

Понравилась статья? Поделить с друзьями:
  • Ошибка no such file found
  • Ошибка no such device ostree
  • Ошибка no such device grub
  • Ошибка no start signal detected forcing start
  • Ошибка no space left on device на android