如果從 Google Play 商店下載 apk 和 obb,則無法在 android 10 設備上訪問 obb 擴展文件 (Cannot reach obb expansion file on android 10 device if apk and obb is downloaded from Google Play store)


問題描述

如果從 Google Play 商店下載 apk 和 obb,則無法在 android 10 設備上訪問 obb 擴展文件 (Cannot reach obb expansion file on android 10 device if apk and obb is downloaded from Google Play store)

我從很多地方尋找解決方案(以編程方式測試是否在 Android 10+ 中禁用了舊版外部存儲訪問https://developer.android.com/google/play/expansion‑files.html#Downloading 等),但不知道錯誤的確切原因。如果僅在 android 10 設備的情況下從 Google Play 下載應用程序,則會出現此錯誤:

Caused by: java.lang.IllegalArgumentException: Couldn't get OBB info for /storage/emulated/0/Android/obb/packageName/main.package_version.packageName.obb

程序可以找到 obb 文件(即使在 android 10 設備上)

File mainFile = new File(Environment.getExternalStorageDirectory() + "/Android/obb/" + packageName + "/" + "main." + packageVersion + "." + packageName + ".obb")
mainFile.getAbsolutpath()

也獲取文件路徑。然而,當存儲管理器用於從 Google Play 商店下載的應用程序時

sm.mountObb(mainFile.getAbsolutePath(), null, mainObbStateChangeListener );

無法訪問 obb 擴展文件並終止應用程序並出現上述錯誤。

可以從 Google Play 下載應用程序,但僅適用於 android 9 或以下設備。如果我創建 apk 並將其安裝在 android 10 設備上,該應用程序可以毫無問題地訪問 obb 文件。從 Google Play 商店下載的應用程序能夠在 android 10 設備上運行時,我錯過了什麼?幫助將不勝感激。

更新:

我在 Android 10 設備上找到了錯誤的原因,但我仍然不知道答案:

如果 apk 版本代碼(app gradle 中的版本代碼)與 obb 文件名中的版本代碼匹配(如果我理解良好的話應該是(. More details of this method can be found here.

(by Zeghraahasbini)

參考文件

  1. Cannot reach obb expansion file on android 10 device if apk and obb is downloaded from Google Play store (CC BY‑SA 2.5/3.0/4.0)

#apk-expansion-files #Android #android-10.0 #google-play






相關問題

從擴展文件播放聲音文件 (Playing sound files from expansion file)

如何掛載加密的APK擴展文件? (How to mount encrypted APK expansion files?)

如何使用jobb工具Android創建OBB文件 (How to create OBB files USING jobb tool Android)

發布不顯示谷歌地圖的 APK 文件 (Release APK file not showing google maps)

PHP - 上傳APK到自己的服務器 (PHP - upload APK to own server)

如果從 Google Play 商店下載 apk 和 obb,則無法在 android 10 設備上訪問 obb 擴展文件 (Cannot reach obb expansion file on android 10 device if apk and obb is downloaded from Google Play store)

APK 擴展文件下載顯示驗證的各種進度 (APK Expansion File Download shows various progress on validation)

APK 擴展文件下載不起作用 (APK Expansion file download doesn´t work)

掛載 .obb 時未調用 OnObbStateChangeListener (OnObbStateChangeListener not called when mounting .obb)

可以掛載未加密的obb但加密錯誤21 (can mount unencrypted obb but with encrypted error 21)

無法在魅族 m3 note 上掛載 .obb 文件(state = 21) (Can't mount .obb file (state = 21) on Meizu m3 note)







留言討論