Closed Oldes closed 5 months ago
Shouldn't you be passing the asset pack id to the fetchAssetPack()
method? Looks like you are passing a filename?
You are right... when I use asset pack id
, the error is gone. The documentation still needs improvements...
I don't have the error, but I don't see expected PlayAssetDeliveryEvent
. This is what I have in the log now:
2024-01-17 11:16:14.780 24068-24068 FetchAsset pid-24068 I FetchAsset
2024-01-17 11:16:14.780 24068-24068 FetchAsset pid-24068 I Input value is [asset_pack2]
2024-01-17 11:16:14.780 24068-24126 PlayCore pid-24068 I UID: [10456] PID: [24068] AssetPackServiceImpl : syncPacks
2024-01-17 11:16:14.780 24068-24068 PlayAssetA...ionContext pid-24068 I setPlayAssetDeliveryManagerObj get
2024-01-17 11:16:14.780 24068-24068 PlayAssetD...eryManager pid-24068 D fetch()
2024-01-17 11:16:14.780 24068-24127 PlayCore pid-24068 I UID: [10456] PID: [24068] AssetPackServiceImpl : Initiate binding to the service.
2024-01-17 11:16:14.780 24068-24068 PlayAssetD...eryManager pid-24068 D fetch() end: status 0
2024-01-17 11:16:14.780 24068-24068 FetchAsset pid-24068 I FetchAsset end
2024-01-17 11:16:14.803 24068-24068 PlayAssetD...eryManager pid-24068 I status: 4, name: asset_pack2, errorCode: 0, bytesDownloaded: 0, totalBytesToDownload: 0, transferProgressPercentage: 0
2024-01-17 11:16:14.803 24068-24068 PlayCore pid-24068 I UID: [10456] PID: [24068] AssetPackServiceImpl : ServiceConnectionImpl.onServiceConnected(ComponentInfo{com.android.vending/com.google.android.finsky.assetmoduleservice.AssetModuleService})
2024-01-17 11:16:14.804 24068-24127 PlayCore pid-24068 I UID: [10456] PID: [24068] AssetPackServiceImpl : linkToDeath
2024-01-17 11:16:14.806 24068-24091 PlayCore pid-24068 I UID: [10456] PID: [24068] AssetPackServiceImpl : onGetSessionStates
2024-01-17 11:16:14.806 24068-24127 PlayCore pid-24068 I UID: [10456] PID: [24068] AssetPackServiceImpl : Unbind from service.
I can see, that the status is 4
(COMPLETED
) in the log, but the sizes are all zero:/ Also without a source code and missing documentation it is not clear to me, how I could access files from the pack?
A combination of the pack id and the asset file name is causing the error again, so it is not the right way to go :-/
Hi
I'm not sure why you're getting the zero size for the bytes downloaded etc.. those are just the values from the Android API (AssetPackState.bytesDownloaded()
etc). Is this a properly published application, or is it going through local testing? https://developer.android.com/guide/playcore/asset-delivery/test
My assumption as to why you don't get the event callback is just that it's likely the garbage collector has run, so if you just had a local object (var assets
) then there would be nothing to keep that around..
To get at the assets, it depends a bit on which type of asset pack...
https://github.com/airsdk/ANE-PlayAssetDelivery/wiki#accessing-assets
asset_pack2
is fast-follow and you'd access things the same as for an on-demand pack, i.e. either find the installation location via getAssetPackLocation
and then add the path to your file; or use getAssetAbsolutePath
. From memory, you wouldn't need to include the asset pack folder name - i.e. from your packaging command, asset pack 2 was in a folder called assetpack2
so if you had a file in here called test.txt
then just use that as the path, rather than assetpack2/test.txt
.
Hope that helps! Conversations re open sourcing have reached the legal team..
Thanks for reply and sorry for so many questions... I am slowly getting forward... I already managed to get fast-follow
pack downloaded (at least using a local testing apk).
I believe that there are some bugs in the latest ANE.. for example calling assets.getAssetPackStatus("asset_pack2")
always gives me 0
, even when I call it from the playAssetDelivery_statusHandler
when the event is PlayAssetStatus.COMPLETED
.
On the other side, calling assets.getAssetAbsolutePath("asset_pack2", "Start.lvl")
from the same place now gives me full path to the file, which is OK.
The PlayAssetDeliveryEvent
events are also somehow heretic... I wanted first fetch the fast-follow
assets and then fetch the on-demand
assets... it goes ok with the first pack, but when I call assets.fetchAssetPack("asset_pack3");
when I receive PlayAssetStatus.COMPLETED
then I receive the COMPLETED
event for the fast pack with each on-demand pack event. It looks that the closed source is maybe reporting status for all packs with every internal change. But that should be maybe as a separate issue.
My code looks like:
case PlayAssetStatus.COMPLETED:
{
if(event.assetPackName == "asset_pack2") {
log("status asset_pack2: "+ assets.getAssetPackStatus("asset_pack2")); // always zero!!!
log("absolutePath: "+ assets.getAssetAbsolutePath("asset_pack2", "Start.lvl")); // OK
// we have the fast follow assets, so let's download the rest!
log("\non-demand assets =====================================");
assets.fetchAssetPack("asset_pack3");
} else {
log("status asset_pack3: "+ assets.getAssetPackStatus("asset_pack3")); // always zero!!!
log(assets.getAssetAbsolutePath("asset_pack3", "Univerzal.lvl")); // OK
// stop resolving any other events as we are done!
assets.removeEventListener( PlayAssetDeliveryEvent.PLAY_ASSET_UPDATE, playAssetDelivery_statusHandler );
}
break;
}
We had shifted the architecture recently, to cope with people having multiple instances of the ANE AS3 class, and that may have caused issues with events being sent to multiple listeners (i.e. any listener would get all events..) - so we may need to check that, it could be a new problem... but yes, let me copy/paste this into a new issue!
I'm closing this issue as it looks that the error from the title is related to a non-existing package.
It would be good to better document in the wiki that the fast-follow
and on-demand
asset packs must be downloaded using the assetPack
id
used in the manifest file. In my case:
var assets:PlayAssetDelivery = new PlayAssetDelivery();
assets.debugMode = true;
if (assets.initAssetDelivery()) {
assets.addEventListener( PlayAssetDeliveryEvent.PLAY_ASSET_UPDATE, playAssetDelivery_statusHandler );
assets.fetchAssetPack("asset_pack2");
}
Maybe it would be also good to have some way how to report an error to user, when invalid or missing assetPack id is used.
I am trying the version 1.2.0 of this ANE. I have these assets in the manifest:
Including all 3 folders when making the AAB package. The
install-time
delivery works as expected, but when I use code like this tofetch
the other packs:I can see this error in the log:
Tested with AIR 50.2.4 and
android:targetSdkVersion="33"