google / play-unity-plugins

The Google Play Plugins for Unity provide C# APIs for accessing various Play services
Other
435 stars 110 forks source link

Failed to retrieve AssetBundle Asset Pack Download Error(-5): The Asset Delivery API is not available. (https://developer.android.com/reference/com/google/android/play/core/assetpacks/model/AssetPackErrorCode.html#API_NOT_AVAILABLE)ssetPackErrorCode.html#API_NOT_AVAILABLE #6

Open efarraro opened 4 years ago

efarraro commented 4 years ago

Is there any guidance on what this error means? I used the version of this library that was distributed via the Google Package Manager in Unity, but I think the question is a general one. I'm not sure how to debug this error.

Adding some additional context here - I was following the Unity integration <> developer guide (https://developer.android.com/guide/playcore/asset-delivery/integrate-unity) and was attempting to test the functionality locally (as described in the docs). adb logcat showed that the bundle failed due to the below error.

Any suggestions on how to debug the Delivery API not being available?

_Failed to retrieve AssetBundle Asset Pack Download Error(-5): The Asset Delivery API is not available. (https://developer.android.com/reference/com/google/android/play/core/assetpacks/model/AssetPackErrorCode.html#API_NOT_AVAILABLE)ssetPackErrorCode.html#API_NOT_AVAILABLE_

efarraro commented 4 years ago

Not 100%, but the issue may be (answering my own question) that the Google Play Instant package via the package manager may be required for the Google Play Asset Delivery to work. Because I'm not building an Instant app, it didn't occur to me that I might need that package. I was only trying to use the Google Play Asset Delivery for Unity.

Was following these instructions https://developer.android.com/guide/app-bundle/asset-delivery/build-unity

thanwah commented 4 years ago

Thank you for letting us know about this.

Do I understand correctly from your 2nd comment that the "-5" error stopped happening after you installed the Google Play Instant package?

If the problem is still happening or if you still have the original logs, you might see if there are any other related log messages a little before you received the "-5" error.

I'll also check with some other teammates to see if they have an idea about this.

efarraro commented 4 years ago

That's correct - after I installed the Google Play Instant package, the error went away. The logs immediately preceding the -5 error were just debug logs after I called the API to retrieve the Unity asset bundle via Play Asset Delivery:

First:

Calling get asset location, assetPackName: coreui, path: assetpack/coreui
04-20 17:25:37.075 19011 19033 I Unity   : Google.Play.AssetDelivery.Internal.AssetPackManager:GetAssetLocation(String, String)
04-20 17:25:37.075 19011 19033 I Unity   : Google.Play.AssetDelivery.Internal.PlayAssetDeliveryInternal:RetrieveAssetBundleAsyncInternal(String)

and following that:

Failed to retrieve AssetBundle Asset Pack Download Error(-5): The Asset Delivery API is not available. (https://developer.android.com/reference/com/google/android/play/core/assetpacks/model/AssetPackErrorCode.html#API_NOT_AVAILABLE): 
04-20 17:25:37.156 19011 19033 E Unity   : Google.Play.AssetDelivery.Internal.<>c__DisplayClass8_1:<RetrieveAssetBundleAsyncInternal>b__1(String, Int32)
04-20 17:25:37.156 19011 19033 E Unity   : System.Action`2:Invoke(T1, T2)
04-20 17:25:37.156 19011 19033 E Unity   : Google.Play.Core.Internal.PlayCoreEventHandler:Update()

My guess is perhaps there's some dependency on Play Instant when retrieving Asset Packs, and that API isn't available unless the Instant package is installed. I'm not using any of the Instant functionality explicitly, so if there is a dependency there, I would assume the Google Package Manager in Unity should handle it (assuming that's the issue)

ScJa commented 4 years ago

Hi,

I can shed some light into this issue:

We offer a set of tools for testing asset delivery locally. Please take a look at let us know if these resolve your issue.

efarraro commented 4 years ago

I actually ran into this error while trying to test as outlined in the doc (Build > Run). It's definitely possible there was some coincidence where I changed something else and thought it was related to the installation of the Instant package. I was mostly so mystified by how the API couldn't be available that I thought it must be either 1) my account somehow needs to be enrolled or 2) the API is literally not available (eg: some service or API is not installed)

I'm happy to close the issue and it can be reopened if anyone else runs into it. Thanks for the quick response!

thanwah commented 4 years ago

Thanks again for filing this. We're still investigating what the cause might be and if there's more we can do to document potential causes of the -5 error.

If you don't mind trying one last thing, could you maybe uninstall the Play Instant package and see if Build & Run works even after it's removed?

efarraro commented 4 years ago

I tried this just now and it did work after I removed Instant (went to Unity Package manager, clicked Play Instant, clicked Remove). I don't know to confirm that the package has been removed. I can tell the package manifest was updated and removed the entry, although I don't know where the packages are stored locally to confirm (or if it's cached).

I don't have time to set this up at the moment, but if I were going to try and reproduce, I'd try and create a fresh Unity project and include the Google Package Manager in Unity and grab all but the Instant / Billing packages (Google Android App Bundle, Google Play Asset Delivery, Google Play Common, Google Play Core). I'd create an asset bundle and then in a Start() method of a script attached to the Scene, I'd call PlayAssetBundleRequest bundleRequest = PlayAssetDelivery.RetrieveAssetBundleAsync(fileName); and see if it works when using Google > Build & Run.

Is it at all possible that there are shared settings between the packages? For instance, a certain flag that's required by Asset Delivery that isn't set unless the Instant package is installed?

binouze commented 3 years ago

Hi, I just launched an update of my game and changed some delivery mode of some bundles from install_time to fast_follow and on_demand to reduce the app size. Since this new update I have some users encountering this problem, 15 users for now with various device (huawei, xiaomi, lenovo, samsung) and android version (8,9,10,11).

Any idea on how to fix this ?

binouze commented 3 years ago

Hi, after further research, it seems that players having this issue didn't download the game from Google Play Store. When I check the install store I see com.google.vending and install mode is Store. Is there another way to detect if the game comes from Google Play Store ?