Assets and APK

627 views
Skip to first unread message

kalmen chia

unread,
May 19, 2016, 12:21:52 AM5/19/16
to DroidScript
Hi ,

Sorry for some dump questions .
Can anyone help me to clarify as i am still confuse with the Asset files and how we can get these files include in our APK.

1. I have a DS project , project-test and i can see that it will have a folder /storage/emulated/DroidScrpt/project-test/*
    where there are Html , Img , folder and other js files etc...

So my questions ,
1. when i generate APK , the local, source code, [Html] folder will map to Html folder , but i saw that the 
    Images is it will map to [img] , the [images] folder name change after APK  ? 
    How about [Misc] , which folder will it be mapped to ?
    and [Sounds]  will map to APK installed app folder ?

2. i have experience this , after i generate APK , all my local source code folder which has the files in the [Html] and all the js files
   i generated but was not actually included even i select to include "Asset files" before generation , i have to manually zip the whole
   source folder and after installed the App , then unZIP the Zip folders which include all the js , Html folders and all its files , 
   the app will then work properly.

3. and in it there is a config file using sqlite db . so what is the best practice of include all files in my APK ?

Thanks ,
Kalmen

sankarshan dudhate

unread,
May 19, 2016, 12:55:43 AM5/19/16
to DroidScript
Hi Kalmen,
I've never before experienced that assets aren't working in apks. I usually am a bit wayward about assets. I usually don't put my images into the 'Img' folder except the app logo and so is true for other files. However, every app I've compiled to an apk works as it should. I wouldn't care where they are as long as the app works.
I see that the /sdcard/DroidScript/appName/* folder is actually analogous to /assets/user/* folder in the apk. Isn't that the case with you ?

kalmen chia

unread,
May 19, 2016, 1:43:07 AM5/19/16
to DroidScript
Hi ,

Thanks for the answer , yes i have checked the APK and found those files is actually inside , but when it installed , these files is not be extracted
as per my Development time , but it seems that i need to somehow try to extract this files from the installation folder /Assets/User 
to the installation folder to actually get my app to work , 

do you have any idea of how ? ( to include this as a zip file ? but i suppose the files in the Asset/user is protected,
i mean at least obscured  , if i have to include the same files , i will need to obscure it before creating my deployment zip ?)

actually what is the best way to do this ?

sankarshan dudhate

unread,
May 19, 2016, 3:07:47 AM5/19/16
to DroidScript
What path are you using for the assets ? "/sdcard/DroidScript/AppName/someimage.png" etc. ?

kalmen chia

unread,
May 19, 2016, 10:17:45 PM5/19/16
to DroidScript
it is as what u mentioned ,

"/sdcard/DroidScript/AppName/Html/some.js"
"/sdcard/DroidScript/AppName/Html/somesqlite.db"
"/sdcard/DroidScript/AppName/Html/*.*"
"/sdcard/DroidScript/AppName/Images/someimage.png"
"/sdcard/DroidScript/AppName/Images/*.*"
"/sdcard/DroidScript/AppName/other.js"
"/sdcard/DroidScript/AppName/*.*"

is this causing the problem ? because after i generate the APK , it cannot run using the APK... of course my guess is that for those under the root
of my AppName , other.js becuase in my code , during development , i have app.loadscript("other.js") ... so will the generated
APK be able to know where to pick up the other.js ?


Message has been deleted

Steve Garman

unread,
May 19, 2016, 11:49:56 PM5/19/16
to DroidScript
You should not use absolute paths in your code for the very reason that they will not be in the same place on a target device.
Try relative paths not starting with "/" instead.

"Html/some.js"
"Html/somesqlite.db"
"Html/*.*"
"Images/someimage.png"
"Images/*.*"
"other.js"
"*.*"

Now that you have built loads of them into your code, I suggest changing them one at a time and run them in DroidScript to see if each one causes you problems.

If you get problems with an individual one because you are using a non-droidscript call to access it, you may need to change that one to
app.GetAppPath() + "/" + "Html/*.*"

Reply all
Reply to author
Forward
0 new messages