下载android扩展文件

时间:2017-02-20 16:26:42

标签: android cordova-plugins apk-expansion-files

我正在创建一个用于下载扩展文件的cordova插件。 目前,我正在实施手动下载扩展文件。

请求将被发送,但我收到错误

aborting request for download main.1000004.my.name.app.obb: while writing destination file: java.io.FileNotFoundException: /storage/emulated/0/Android/obb/my.name.app/main.1000004.my.name.app.obb.tmp: open failed: ENOENT (No such file or directory)
02-20 17:12:12.930 15355-15631/my.name.app W/System.err: com.google.android.vending.expansion.downloader.impl.DownloadThread$StopRequest: while writing destination file: java.io.FileNotFoundException: /storage/emulated/0/Android/obb/my.name.app/main.1000004.my.name.app.obb.tmp: open failed: ENOENT (No such file or directory)
W/System.err:     at com.google.android.vending.expansion.downloader.impl.DownloadThread.writeDataToDestination(DownloadThread.java:515)
W/System.err:     at com.google.android.vending.expansion.downloader.impl.DownloadThread.transferData(DownloadThread.java:350)
W/System.err:     at com.google.android.vending.expansion.downloader.impl.DownloadThread.executeDownload(DownloadThread.java:308)
W/System.err:     at com.google.android.vending.expansion.downloader.impl.DownloadThread.run(DownloadThread.java:236)
W/System.err:     at com.google.android.vending.expansion.downloader.impl.DownloaderService.onHandleIntent(DownloaderService.java:1086)
W/System.err:     at com.google.android.vending.expansion.downloader.impl.CustomIntentService$ServiceHandler.handleMessage(CustomIntentService.java:104)
W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err:     at android.os.Looper.loop(Looper.java:148)
W/System.err:     at android.os.HandlerThread.run(HandlerThread.java:61)
W/System.err: Caused by: java.io.FileNotFoundException: /storage/emulated/0/Android/obb/my.name.app/main.1000004.my.name.app.obb.tmp: open failed: ENOENT (No such file or directory)
W/System.err:     at libcore.io.IoBridge.open(IoBridge.java:452)
W/System.err:     at java.io.FileOutputStream.<init>(FileOutputStream.java:87)
W/System.err:     at java.io.FileOutputStream.<init>(FileOutputStream.java:127)
W/System.err:     at com.google.android.vending.expansion.downloader.impl.DownloadThread.writeDataToDestination(DownloadThread.java:496)
W/System.err:   ... 8 more
W/System.err: Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
W/System.err:     at libcore.io.Posix.open(Native Method)
W/System.err:     at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
0W/System.err:    at libcore.io.IoBridge.open(IoBridge.java:438)

实际上,我目前的主要扩展版本是1000013.但它搜索的是1000004.内容是相同的,所以不是问题。

应该有权利

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

知道为什么会这样吗?

2 个答案:

答案 0 :(得分:2)

我认为这种情况正在发生,因为Google Play控制台没有与您当前版本代码相关联的正确扩展文件。确保您在Play Console中上传并选择了正确的扩展文件以及APK。

如果没有帮助,请通过拨打Helpers.isExternalMediaMounted()检查您的外部存储是否可以装入。您的设备可能没有SD卡(模拟器?)。此外,您可能需要通过调用Helpers.canWriteOBBFile(Context)来检查您的应用是否可以访问OBB目录。

我建议使用Better APK Expansion包中包含的更新的下载程序库。它修复了几个问题,并提供简化的API,最大限度地减少了自己射击脚的机会。

答案 1 :(得分:0)

如果您到达此处却找不到答案,请尝试将其添加到Mainfests <application android:requestLegacyExternalStorage="true" ... >