airsdk / ANE-PlayAssetDelivery

Play Asset Delivery ANE
MIT License
2 stars 2 forks source link

1120 _assets access of undefined property #4

Closed mehmury closed 2 years ago

mehmury commented 2 years ago

I am testing Play Asset Delivery ane in my apps.

<assetPacks>
         <assetPack delivery="install-time" folder="Ap_Images" id="Ap_Images_asset_pack"/>
       </assetPacks>

I want to use the files I installed with install-time to access them from within the application. I found out that there is no path defined in apk for install-time. I want to access and upload the file with a simple readBytes method. I downloaded the last ane and edited the codes according to the description here. but I keep getting an error, I am attaching the error code. How should I proceed from here?

var bmp: Loader = new Loader();
    var sayfa4mc: supercetineng = new supercetineng();
    var assets: PlayAssetDelivery = new PlayAssetDelivery();

    if (assets.initAssetDelivery()) {
        // PlayAssetDelivery initialised

        var asset: AssetFile = _assets.openInstallTimeAsset("Ap_Images/supercetineng.swf");

        if (asset != null) {

            var bytes = new ByteArray();
            asset.readBytes(bytes);

            asset.close();
            var cont: LoaderContext = new LoaderContext();
            cont.allowCodeImport = true;

            bmp.contentLoaderInfo.addEventListener(Event.COMPLETE, handleAppLoaded);
            bmp.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, handleProgress);

            bmp.loadBytes(bytes, cont);

            function handleProgress(e: ProgressEvent): void {

                sayfa4mc.x = 0;
                sayfa4mc.y = 0;
                addChild(sayfa4mc);
                addChildAt(sayfa4mc, 0);
            }

            function handleAppLoaded(e: Event): void {

                sayfa4mc.x = 0;
                sayfa4mc.y = 0;
                bmp.x = 0;
                bmp.y = 0;
                sayfa4mc.addChild(bmp);
                sayfa4mc.addChildAt(bmp, 1);
            }
            ``
![error](https://user-images.githubusercontent.com/51246471/147097940-9fd7be0b-38cd-4865-bb33-a8fcf6eb2ed9.png)

        }
ajwfrost commented 2 years ago

That looks like just a typo?

    var assets: PlayAssetDelivery = new PlayAssetDelivery();
    if (assets.initAssetDelivery()) {
        var asset: AssetFile = _assets.openInstallTimeAsset("Ap_Images/supercetineng.swf");

The "PlayAssetDelivery" variable is defined as assets so when you then have _assets.openInstallTimeAsset it wouldn't know what _assets is...

mehmury commented 2 years ago

Sorry, I got confused while testing. In the examples used as _assets, I used copy paste that code. I fixed it and used it as assets. I am attaching all of the encoding I posted. when I use it this way I wanted to get status to verify the contents of the defined file. This time I get an error for PlayAssetDeliveryEvent. With the install-time feature, is it possible to access the assets files in the apk with this ane?

import com.harman.extension.PlayAssetDelivery; import com.harman.extension.AssetFile; import com.harman.extension.PlayAssetStatus;

var sayfa4mc: supercetineng = new supercetineng();

var bmp: Loader = new Loader();

if (MovieClip(root).monitorkontrol == 0) { trace("monitor 0");

var assets: PlayAssetDelivery = new PlayAssetDelivery();

if (assets.initAssetDelivery()) {
    // PlayAssetDelivery initialised

    var asset: AssetFile = assets.openInstallTimeAsset("Ap_Images/supercetineng.swf");

    assets.addEventListener(PlayAssetDeliveryEvent.PLAY_ASSET_UPDATE, playAssetDelivery_statusHandler);

    // Init / fetch etc

    function playAssetDelivery_statusHandler(event: PlayAssetDeliveryEvent): void {
        trace("asset pack name: " + event.assetPackName);
        trace("status: " + PlayAssetStatus.getStatus(event.status)); // Value from PlayAssetStatus

        switch (event.status) {
            case PlayAssetStatus.COMPLETED:
                {
                    // An asset pack fetch was completed
                    break;
                }
        }
    }

    if (asset != null) {

        var bytes = new ByteArray();
        asset.readBytes(bytes);

        asset.close();
        var cont: LoaderContext = new LoaderContext();
        cont.allowCodeImport = true;

        bmp.contentLoaderInfo.addEventListener(Event.COMPLETE, handleAppLoaded);
        bmp.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, handleProgress);

        bmp.loadBytes(bytes, cont);

        function handleProgress(e: ProgressEvent): void {

            sayfa4mc.x = 0;
            sayfa4mc.y = 0;

            ilksayfa.visible = false;
            ana.visible = false;
            firstpage.visible = false;
            mainmenu.visible = false;
            oksol.visible = false;
            oksag.visible = false;
            buyut.visible = false;
            kucult.visible = false;

            addChild(sayfa4mc);
            addChildAt(sayfa4mc, 0);
        }

        function handleAppLoaded(e: Event): void {

            sayfa4mc.x = 0;
            sayfa4mc.y = 0;
            ilksayfa.visible = false;

            ana.visible = false;
            firstpage.visible = true;
            mainmenu.visible = true;
            oksol.visible = true;
            oksag.visible = true;
            buyut.visible = true;
            kucult.visible = false;
            numb = 4;
            bmp.x = 0;
            bmp.y = 0;
            sayfa4mc.prmc.visible = false;
            sayfa4mc.addChild(bmp);
            sayfa4mc.addChildAt(bmp, 1);
        }

    } else {
        trace("nothing!

error2 "); }

}

}

ajwfrost commented 2 years ago

Google Translate thinks that your compilation error is that you don't have a definition for the type "PlayAssetDeliveryEvent" .. which you wouldn't have, unless you include the line: import com.harman.extension.PlayAssetDeliveryEvent;

mehmury commented 2 years ago

var asset: AssetFile = assets.openInstallTimeAsset("Ap_Images_asset_pack/assets/supercetineng.swf");

I tried all day, but without success. my goal is to pack android aab with play asset delivery ane and access additional swf files in assets folder. I don't want to do this with on-demand or fast-fallow. I want to use the install-time feature. However, the path given with the openInstallTimeAsset command does not work even though I have tried many things. Lastly, I used the path in the aab folder, but that didn't work either. Is it possible to use install-time feature with play asset delivery ane? thanks... file1 file2 file3

jimmymjing commented 2 years ago

Hi, I think we can't have swfs in Asset Packs. Please correct me if I'm wrong.

ajwfrost commented 2 years ago

Hi It should be fine to have any file type in these assets. Given the folder structure shown above, the command should be:

var asset: AssetFile = assets.openInstallTimeAsset("supercetineng.swf");

since the asset pack folder (in the app descriptor xml) is just used for identifying the files, the ID is then used in the Bundle as a folder name, but this then uses the 'assets' folder as the base of what's available. So any file within your "asset pack folder" (from the app descriptor) are directly available with just that filename.

e.g. if you have folder="Ap_Images in the XML, and a file in the folder Ap_Images/test.swf, then you can use openInstallTimeAsset("test.swf")

mehmury commented 2 years ago

Sorry!! I try that way.I use only file name... It turns null !!!

import com.harman.extension.*;

var _assets: PlayAssetDelivery = new PlayAssetDelivery();

_assets.initAssetDelivery();

var asset:AssetFile = _assets.openInstallTimeAsset("supercetineng.swf");

I think packge cannot install right way at google Play console. I try direct Google Play Console internal test but my all tries it turns null!!

ajwfrost commented 2 years ago

So that sort of approach had worked for us when we were testing, using the --local-testing flag when creating the APKS set to install.

When you install it, you should see a bunch of APKs being copied onto the device, and it should then be possible to check these via ADB. Do you see a separate APK that contains those files?

We can try to investigate it from your AAB file if it's possible for you to send it to us? https://transfer.harman.com/requests/HOoIFX4N7VJBKlnBFzFoYa

thanks

mehmury commented 2 years ago

I tried to do local test operations with java bundletool tool. I used two separate android devices. Android 4.4.2 is installed on the first device. I got the error that sdk is not supported on this device. The second device is android 7.0 installed. This device was also installed, but as you said, I could not see the files in the apks. I am posting my results. I will also forward the aab file to you, there is no problem in this regard.. adtbundle appbundle2

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

mehmury commented 2 years ago

Is there any progress on this issue? Will there be a new version for the play assets delivery ane? Also, does the play assets delivery ane work by itself? Do I need to use it with apm?

ajwfrost commented 2 years ago

Hi - the latest version is available from the below link, you can use it without using apm if you want, apm just simplifies the process of adding it and its dependencies into a project..

https://github.com/airsdk/ANE-PlayAssetDelivery/tree/main/build

This should all work fine, let us know if you have any issues; looking at the above screenshots, it looks like one device had got into a partial state but uninstalling and re-installing the APKS should have solved that?

thanks

mehmury commented 2 years ago

i will test this apks again.thanks!!

mehmury commented 2 years ago

Hello again!! I tested my application again with the new playassetsdelivery.ane. It's still the same thing when I install the app on my device with bundletool. I am constantly unable to see the package contents. and it returns null.

When I want to test with the --local-test command, the result is as I posted below.

I cannot use playassetsdelivery.ane.

the packaging method I used in the last test install-time and the actionscript script I use:

import com.harman.extension.*;
var apPath:String=new String("");
var _assets: PlayAssetDelivery = new PlayAssetDelivery();

_assets.initAssetDelivery();

var asset:AssetFile =_assets.openInstallTimeAsset("supercetineng.swf");

apPath=_assets.getAssetPackLocation("supercetineng.swf");   

if (asset != null)
{
    // Load some text content from the asset
    var content:Object = asset.readUTFBytes(asset.bytesAvailable );
    asset.close();
}
D:\cizgioyaab>java -jar bundletool.jar install-apks --apks=dbn.apks
The APKs have been extracted in the directory: C:\Users\geuge\AppData\Local\Temp\6035349858916915910
The APKs have been extracted in the directory: C:\Users\geuge\AppData\Local\Temp\6035349858916915910
ADB << rm -rf '/sdcard/Android/data/air.xetna/files/local_testing'
ADB >> OK
ADB << mkdir -p '/sdcard/Android/data/air.xetna/files/local_testing' && rmdir '/sdcard/Android/data/air.xetna/files/local_testing' && mkdir -p '/sdcard/Android/data/air.xetna/files/local_testing'
ADB >> OK
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-xxhdpi.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-master_2.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-tr.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-ca.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-da.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-fa.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-ja.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-ka.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-pa.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-ta.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-nb.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-be.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-de.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-ne.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-te.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-af.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-bg.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-th.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-fi.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-hi.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-si.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-vi.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-kk.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-mk.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-sk.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-uk.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-el.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-gl.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-ml.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-nl.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-pl.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-sl.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-tl.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-am.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-km.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-bn.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-in.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-kn.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-mn.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-ko.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-lo.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-ro.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-sq.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-ar.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-fr.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-hr.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-mr.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-or.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-sr.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-ur.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-as.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-bs.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-cs.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-es.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-is.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-ms.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-et.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-it.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-lt.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-pt.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-eu.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-gu.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-hu.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-ru.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-zu.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-lv.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-sv.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-iw.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-sw.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-hy.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-ky.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-my.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-az.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-uz.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-en.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-zh.apk"
Pushed "/sdcard/Android/data/air.xetna/files/local_testing/base-arm64_v8a_2.apk"
ADB << run-as 'air.xetna' rm -rf '/data/data/air.xetna/files/splitcompat'
ADB >> run-as: package not debuggable: air.xetna
Failed to remove working directory with local testing splits. Your app might still have been installed correctly but have previous version of dynamic feature modules. If you see legacy versions of dynamic feature modules installed try to uninstall and install the app again.

D:\cizgioyaab>
github-actions[bot] commented 2 years ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] commented 2 years ago

This issue was closed because it has been stalled for 5 days with no activity.