Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
How to require "dataSaver" class in init.lua? — Gideros Forum

How to require "dataSaver" class in init.lua?

Apollo14Apollo14 Member
edited November 2019 in Code snippets
Hi guys!

I have a question about this class: http://appcodingeasy.com/Gideros-Mobile/Save-and-load-data-module-for-Gideros-Mobile
How can I require "dataSaver" inside 'init.lua'?
I'm doing slight mistake somewhere:

If I write this code, it works on Gideros Android Player, but doesn't work on packaged apk:
image

Release apk gets crached and writes that there's no "classes/dataSaver.lua" file.
com.giderosmobile.android.player.LuaException: init.lua:55: module 'classes/dataSaver' not found:
	no field package.preload['classes/dataSaver']
	no file './classes/dataSaver.lua'
	no file './classes/dataSaver/init.lua'
	no file './_LuaPlugins_/classes/dataSaver.lua'
	no file './_LuaPlugins_/classes/dataSaver/init.lua'
	no file '/usr/local/share/lua/5.1/classes/dataSaver.lua'
	no file '/usr/local/share/lua/5.1/classes/dataSaver/init.lua'
	no file '/usr/local/lib/lua/5.1/classes/dataSaver.lua'
	no file '/usr/local/lib/lua/5.1/classes/dataSaver/init.lua'
	no file './classes/dataSaver.so'
	no file '/usr/local/lib/lua/5.1/classes/dataSaver.so'
	no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
	init.lua:55: in main chunk
	(luac): in main chunk
	at LUA.MAIN_CHUNK(init.lua:55)
	at LUA.MAIN_CHUNK(luac:1234)
But this file is there. And "JSON" plugin is included in my project's settings.


Also I've tried to edit "code dependencies" of init.lua, it still can't find "classes/dataSaver.lua"
image
require_inside_init_file.jpg
857 x 275 - 100K
z_code_dep.jpg
347 x 479 - 87K
z_code_dep2.jpg
700 x 479 - 153K
> Newcomers roadmap: from where to start learning Gideros
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)

Comments

  • hgy29hgy29 Maintainer
    Accepted Answer
    you must mark every "require"'ed lua file is 'exclude from execution' in gideros studio, otherwise all lua files are merged together into a single main.lua file

    Likes: SinisterSoft

    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.