# FMOD Android: error 18, File not found

**URL:** <https://qa.fmod.com/t/fmod-android-error-18-file-not-found/15759>\
**Category:** FMOD Engine\
**Created:** [May 12, 2020, 12:07pm UTC](https://qa.fmod.com/t/fmod-android-error-18-file-not-found/15759 "2020-05-12T12:07:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dani5h](https://avatars.discourse-cdn.com/v4/letter/d/3be4f8/32.png) [@dani5h](https://qa.fmod.com/u/dani5h)\
**Post date:** [May 12, 2020, 12:07pm UTC](https://qa.fmod.com/t/fmod-android-error-18-file-not-found/15759/1 "2020-05-12T12:07:50Z")

</div>

Hi, I am using FMOD for the first time. Facing some errors in code, seeking for help. ASAP  
I have successfully imported audio from Android to FMOD native c++, added dsp filters and effects, Created the sound, Played the sound. Now it was time to SAVE the sound to android specific folder.  
But I am getting an error while doing so.  
When i put this Line of code:  
`result = system->setOutput(FMOD_OUTPUTTYPE_WAVWRITER_NRT)`

i get this error:  
`Error 18, File not found.`

I created input sound file and output sound empty file path from Android side, and they do exists. Input is working fine but giving error on saving the file.  
Need urgent help.

---

<div class="post-metadata">

**Author:** ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)\
**Post date:** [May 13, 2020, 2:21am UTC](https://qa.fmod.com/t/fmod-android-error-18-file-not-found/15759/2 "2020-05-13T02:21:21Z")

</div>

It sounds like the path for writing the output wav isn’t accessible.  
What path are you giving to System::init?

Internally we take the path passed via extradriverdata and do the following:  
`mFP = fopen(mFileName, "wb");`

As a test you could ensure that works before calling System::init?

---

<div class="post-metadata">

**Author:** ![dani5h](https://avatars.discourse-cdn.com/v4/letter/d/3be4f8/32.png) [@dani5h](https://qa.fmod.com/u/dani5h)\
**Post date:** [May 13, 2020, 7:02am UTC](https://qa.fmod.com/t/fmod-android-error-18-file-not-found/15759/3 "2020-05-13T07:02:51Z")

</div>

Sorry, Don’t know much about FMOD, i tried following solution but didn’t work.

1. Created File in android, Its visible in file manager now.  
`mFileName = Environment.getExternalStorageDirectory().absolutePath + "/voiceChanger/savedRecording.wav`

2. Called Native C++ from android side and passed file parameter  
`public static native void fix(String path);`

3. On Native side, got the path successfully and tried to save file in that path.

`extern "C" JNIEXPORT void JNICALL my_function_fix(JNIEnv *env, jclass jcls, jstring path) {`  
//Attribute related to Path are posted Only  
`void *extraDriverData = NULL;`  
`const char *path_cstr = env->GetStringUTFChars(path, NULL);`  
`extraDriverData = *path_cstr;`  
`system->setOutput(FMOD_OUTPUTTYPE_WAVWRITER_NRT);`  
`system->init(32, FMOD_INIT_NORMAL, extraDriverData);`  
`}`  
Getting Error on System-init (18) File Not Found.  
Can you please tell me what code to change with code eloboration.

---

<div class="post-metadata">

**Author:** ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)\
**Post date:** [May 14, 2020, 4:14am UTC](https://qa.fmod.com/t/fmod-android-error-18-file-not-found/15759/4 "2020-05-14T04:14:53Z")

</div>

Instead of calling `system->init(32, FMOD_INIT_NORMAL, extraDriverData);`

Try `system->init(32, FMOD_INIT_NORMAL, (void *)path_cstr);`

---

<div class="post-metadata">

**Author:** ![dani5h](https://avatars.discourse-cdn.com/v4/letter/d/3be4f8/32.png) [@dani5h](https://qa.fmod.com/u/dani5h)\
**Post date:** [May 14, 2020, 7:42am UTC](https://qa.fmod.com/t/fmod-android-error-18-file-not-found/15759/5 "2020-05-14T07:42:59Z")

</div>

With using this  
`system->init(32, FMOD_INIT_NORMAL, (void *)path_cstr);`  
File not found error is solved.  
But this  
`system->setOutput(FMOD_OUTPUTTYPE_WAVWRITER_NRT);`  
is producing 0kb file.  
Then I tried using  
`system->setOutput(FMOD_OUTPUTTYPE_WAVWRITER);`  
which is writing file first time successfully, next time android isn’t able to play file.

And is there any way to track progress while saving the file?

---

<div class="post-metadata">

**Author:** ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)\
**Post date:** [May 15, 2020, 12:33am UTC](https://qa.fmod.com/t/fmod-android-error-18-file-not-found/15759/6 "2020-05-15T00:33:26Z")

</div>

When using FMOD\_OUTPUTTYPE\_WAVWRITER\_NRT, you need to call System::update for any mixing to happen, this is the non-realtime (NRT) component of wav writer. Each call to update will produce 512 samples of audio output. Using FMOD\_OUTPUTTYPE\_WAVWRITER internally a thread is created that will do the writing in real-time.

The file will be written synchronously with each mixer update, make sure you call System::release at the end to properly terminate the output file with the correct file length.

---

<div class="post-metadata">

**Author:** ![dani5h](https://avatars.discourse-cdn.com/v4/letter/d/3be4f8/32.png) [@dani5h](https://qa.fmod.com/u/dani5h)\
**Post date:** [May 15, 2020, 6:43am UTC](https://qa.fmod.com/t/fmod-android-error-18-file-not-found/15759/7 "2020-05-15T06:43:41Z")

</div>

ThankYou, @mathew.
