Pregunta

I have been developing an app using CMU Shpinx. I had no problem with it before, but all of a sudden, I cannot sync assets with my external directories. The problem arose from this statement.

            root = syncAssets(getApplicationContext(), "models");

and the stack trace is here.

11-12 19:55:53.440: W/System.err(30395): java.io.FileNotFoundException: /models/dictation/6111.dic: open failed: ENOENT (No such file or directory)
11-12 19:55:53.440: W/System.err(30395):    at libcore.io.IoBridge.open(IoBridge.java:416)
11-12 19:55:53.440: W/System.err(30395):    at java.io.FileOutputStream.<init>(FileOutputStream.java:88)
11-12 19:55:53.440: W/System.err(30395):    at java.io.FileOutputStream.<init>(FileOutputStream.java:73)
11-12 19:55:53.440: W/System.err(30395):    at edu.cmu.pocketsphinx.SphinxUtil.copyAsset(Unknown Source)
11-12 19:55:53.440: W/System.err(30395):    at edu.cmu.pocketsphinx.SphinxUtil.copyAsset(Unknown Source)
11-12 19:55:53.440: W/System.err(30395):    at edu.cmu.pocketsphinx.SphinxUtil.copyAsset(Unknown Source)
11-12 19:55:53.440: W/System.err(30395):    at edu.cmu.pocketsphinx.SphinxUtil.syncAssets(Unknown Source)
11-12 19:55:53.440: W/System.err(30395):    at edu.cmu.pocketsphinx.demo.Recognizer.onCreate(Recognizer.java:175)
11-12 19:55:53.440: W/System.err(30395):    at android.app.ActivityThread.handleCreateService(ActivityThread.java:2382)
11-12 19:55:53.440: W/System.err(30395):    at android.app.ActivityThread.access$1600(ActivityThread.java:137)
11-12 19:55:53.440: W/System.err(30395):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1293)
11-12 19:55:53.440: W/System.err(30395):    at android.os.Handler.dispatchMessage(Handler.java:99)
11-12 19:55:53.440: W/System.err(30395):    at android.os.Looper.loop(Looper.java:137)
11-12 19:55:53.440: W/System.err(30395):    at android.app.ActivityThread.main(ActivityThread.java:4827)
11-12 19:55:53.440: W/System.err(30395):    at java.lang.reflect.Method.invokeNative(Native Method)
11-12 19:55:53.440: W/System.err(30395):    at java.lang.reflect.Method.invoke(Method.java:511)
11-12 19:55:53.440: W/System.err(30395):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
11-12 19:55:53.440: W/System.err(30395):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
11-12 19:55:53.440: W/System.err(30395):    at dalvik.system.NativeStart.main(Native Method)
11-12 19:55:53.440: W/System.err(30395): Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
11-12 19:55:53.440: W/System.err(30395):    at libcore.io.Posix.open(Native Method)
11-12 19:55:53.440: W/System.err(30395):    at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
11-12 19:55:53.440: W/System.err(30395):    at libcore.io.IoBridge.open(IoBridge.java:400)
11-12 19:55:53.440: W/System.err(30395):    ... 18 more

I am sure the asset is there, but am not sure whether the path /models/dictation/6111.dic is correct ? If it is, it should work well. What causes this to go wild?

Any help would be greatly appreciated!

--update--

I later found the state of sdcard is shared as defined here

String | MEDIA_SHARED | Storage state if the media is present not mounted, and shared via USB mass storage.

So How can I do do mount the sdcard?

¿Fue útil?

Solución

Ok, I fixed the issue. Now if external directory is not enabled an exception will be thrown.

In order to fix your problem you should either unplug the device from USB or connect it for USB debugging not "as a media device". On Nexus 4 there is a top menu which you can slide down and pick another mounting option.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top