Task not working when exported to app

57 views
Skip to first unread message

Danielo515

unread,
Mar 23, 2015, 3:12:21 AM3/23/15
to tas...@googlegroups.com
Hello

I have a task that works flawlessly when I run it from Tasker. It's basically a webview that uses some JS libraries. There is an installation task that copies the code of those libraries to global variables if they don't exists. Then the webview reads those libraries from the globals variables directly. But when I export it as an application it does not works.

I don't even know how to troubleshoot this. I tried checking the development app option but I can't see any log. The installation task seems to not be executed in any case. Any clue? Thanks!


TASK-GUI-globals (83)
A1: [X] Read File [ File:Tasker/javascript/lib/datatables/media/js/jquery.dataTables.min.js To Var:%Datatables ]
A2: [X] Read File [ File:Tasker/javascript/lib/datatables/media/js/jquery.js To Var:%Jquery ]
A3: Perform Task [ Name:datatablesInstall Priority:%priority+1 Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: Stop:Off ] If [ %Datatables !Set | %Jquery !Set ]
A4: Read File [ File:/sdcard/Tasker/data/DBs/tareas To Var:%data ]
A5: Variable Set [ Name:%columns To:[
{"data":"title", "name":"Desc"},
{"data":"completed",
"name":"Completed"}
] Do Maths:Off Append:Off ]
A6: Show Scene [ Name:1080_1700-Globals Display As:Dialog Horizontal Position:100 Vertical Position:100 Animation:None Show Exit Button:On Continue Task Immediately:Off ]
A7: Destroy Scene [ Name:1080_1700-Globals ]

Marta Hintz

unread,
Mar 23, 2015, 3:09:01 PM3/23/15
to tas...@googlegroups.com
Not sure If this helps, but someone found a workaround to be able to add a file to a kid app. They posted here on this forum. That was what had broke their kid app. I doubt know if it is the same for your libraries. I think the app has a log file you can check if you haven't already.

Danielo515

unread,
Mar 27, 2015, 10:36:17 AM3/27/15
to tas...@googlegroups.com
Hello Marta,

I did not find any log. I readed a lot about how to include files in child apps, and I think my system is better. This is a small modification to avoid file creation at all. It works while on tasker and it is not using any file, just the text contained on the script files.

Jeremy Harris

unread,
Mar 27, 2015, 2:57:43 PM3/27/15
to tas...@googlegroups.com
Could you post the description for datatablesinstall?

This is the method I use to install initialization files on the first run of one of my apps...no java but it works reliably and very quickly. My file is packed in the apk by compressing a folder into a zip, renaming to a .png extension, and attaching it to a task as an icon.

I'm interested to see your method and I'll try to troubleshoot if I can.

Initialize (365)
A1: Flash [ Text:Installing files! Please wait... Long:On ]
A2: Create Directory [ Dir:HuntingTimes/httemp Create All:On Use Root:Off ]
A3: Create Directory [ Dir:HuntingTimes/Logs Create All:On Use Root:Off ]
A4: Copy File [ From:/data/app/com.jeremy.huntingtimes-1.apk To:HuntingTimes/httemp/com.jeremy.huntingtimes.zip Use Root:Off ]
A5: UnZip [ File:HuntingTimes/httemp/com.jeremy.huntingtimes.zip Delete Zip:Off ]
A6: Copy File [ From:HuntingTimes/httemp/res/drawable/cust_ambilwarna_hue.png To:HuntingTimes/Solunar.zip Use Root:Off ]
A7: Delete Directory [ Dir:HuntingTimes/httemp Recurse:On Use Root:Off ]
A8: UnZip [ File:HuntingTimes/Solunar.zip Delete Zip:On ]

Jeremy Harris

unread,
Mar 27, 2015, 3:22:28 PM3/27/15
to tas...@googlegroups.com
Also wanted to mention that my app also installs a .js library which is used by a Web View.

:)

Danielo515

unread,
Mar 27, 2015, 5:29:33 PM3/27/15
to tas...@googlegroups.com
Hello Jeremy,


El viernes, 27 de marzo de 2015, 20:22:28 (UTC+1), Jeremy Harris escribió:
Also wanted to mention that my app also installs a .js library which is used by a Web View.

:)

I just checked my first post and I noticed that the task to "install the libraries" is not included. I though tasker includes every related task in the description. Here is such task:

datatablesInstall (110)
A1: JavaScript [ Path:Tasker/javascript/lib/encoded_jquery.js.js Libraries: Auto Exit:On Timeout (Seconds):45 ] 
A2: Variable Set [ Name:%Jquery To:%source Do Maths:Off Append:Off ] 
A3: JavaScript [ Path:/sdcard/Tasker/javascript/lib/encoded_jquery.dataTables.min.js.js Libraries: Auto Exit:On Timeout (Seconds):45 ] 
A4: Variable Set [ Name:%Datatables To:%source Do Maths:Off Append:Off ] 
A5: JavaScript [ Path:Tasker/javascript/lib/encoded_jquery.dataTables.min.css.js Libraries: Auto Exit:On Timeout (Seconds):45 ] 
A6: Variable Set [ Name:%Styles To:%source Do Maths:Off Append:Off ] 
A7: Flash [ Text:Installed Long:Off ] 

As you can see the key part are a couple of javascript files. Those javascript files "decodes" the file in binary  format and then set a local variable with the content. Then that  variable text is saved to a global variable. That is how I load the libraries on the memory. Then I just use eval on the web view to make that libraries available.

The task that creates the "encoded files" is very simple:

EncodeFile-text (107)
A1: [X] Variable Set [ Name:%fullpath To:/sdcard/Tasker/javascript/lib/datatables/media/css/jquery.dataTables.min.css Do Maths:Off Append:Off ] 
A2: [X] Variable Set [ Name:%fullpath To:/sdcard/Tasker/javascript/lib/datatables/media/js/jquery.js Do Maths:Off Append:Off ] 
A3: Variable Set [ Name:%fullpath To:/sdcard/Tasker/javascript/lib/datatables/media/js/jquery.dataTables.min.js Do Maths:Off Append:Off ] 
A4: JavaScriptlet [ Code:var filename = fullpath.replace(/^.*[\\\/]/, ''); Libraries: Auto Exit:On Timeout (Seconds):45 ] 
A5: JavaScriptlet [ Code:var path = fullpath.replace(/[^\/]*$/, ''); Libraries: Auto Exit:On Timeout (Seconds):45 ] 
A6: Read File [ File:%path%filename To Var:%source ] 
A7: Variable Convert [ Name:%source Function:URL Encode Store Result In:%enc_source ] 
A8: JavaScriptlet [ Code:var encoded="var filename='"+filename+"'; var source= convert('"+enc_source+"','urlDecode');"; Libraries: Auto Exit:On Timeout (Seconds):45 ] 
A9: Write File [ File:Tasker/javascript/lib/encoded_%filename.js Text:%encoded Append:Off Add Newline:On ] 


I tried a different approach writing the file contents to a real file in the file system and it works perfectly. But for me that is more complicated since I have to know to which folder should I "decompress" the files and that is something I'm not sure about. Looks like you have to use the same folder as your app name, but I'm not sure about this.

Jeremy Harris

unread,
Mar 28, 2015, 5:44:49 AM3/28/15
to tas...@googlegroups.com
Thanks Danielo,

Does the user need to have tasker for your app to run? Or its directory?

I've had to teach myself anything I know about java/JavaScript, so things come slowly for me but I think I'm starting to understand the logic.

Danielo515

unread,
Mar 28, 2015, 9:31:29 AM3/28/15
to tas...@googlegroups.com
Hello Jeremy,

First of all I want to remark that this is not working, that's why I'm asking for help here. The idea of this approach is to use global variables as storage for the libraries so I don't have to care about any kind of file.

My other approach (copying the decoded libraries to a file) works perfectly. The problem is that I don't want to worry about folders because Android is getting more and more restrictive about writing to the Sd
Reply all
Reply to author
Forward
0 new messages