"package.path" can't run normally on the phone

Hello everyone, I’m having a little trouble.

I follow the guidelines given by @vlads in other chapters.

[lua]package.path = package.path … ‘;’ … system.pathForFile( nil, system.DocumentsDirectory ) … “/?.lua”[/lua]

local path = system.pathForFile( nil, system.DocumentsDirectory )
package.path = package.path .. "; "..path.."/All_M_File/?.lua"
local AllRedTipControl = require("All_M_File.AllRedTipControl")

This code can correctly call the Lua file in DocumentsDirectory on the simulator.

But it keeps making mistakes on the phone, no matter if I replace / to \ the result is the same.

I showed package.path to the bottom progress bar text.

Hope someone can help me, thank you.

You can’t directly source lua files out of the documents folder like that.

You need to use a technique like patcher.lua does.

FREE:

DOCS (don’t use as plugin, but instead add directly to project and require it ):
https://roaminggamer.github.io/RGDocs/pages/Plugins/patcher/

1 Like

Thank you,

When I wake up, I will try it immediately and tell you the result.

Since I have been working for 17 hours, I must sleep now. :sob:

Thanks again.

@roaminggamer

Now it can run.

I found that I have a question about TexturepackerHelper before, you have provided a patcher.

But because it can be used normally on the simulator, I ignore it and forget it. :sob:

Now that all problems have been solved, I am really grateful.

Thank you very much. :hugs:

@roaminggamer

Regards,

After using the patcher for a while, I ran into some troubles.

When I use Amazon S3 to download data for hot update, about 20 times, there will be a picture like the top of this article.
【 I cannot be “require” document’s data】

The problem only occurred on the mobile phone, and when I deleted the APP and reinstalled it, everything worked normally.

The data of the APP before deletion is exactly the same as that of the reinstalled APP.

Which is a bit confusing. :sob:

I want to ask if I missed something in the patcher settings?

I always set it at the top of main.lua↓

-----------------------------------------------------------------------------------------
--
-- main.lua
--
display.setStatusBar(display.HiddenStatusBar)
----------------------------------------------------------------------------------------- 

local patcher = require "patcher"
patcher.export() 
patcher.enabled(true)

Ideas
It sounds like the script you are downloading is getting corrupted.

Did you detect any errors in the download process?

If you can readily reproduce this, you should try this:

  1. Download script.
  2. Open it like a text file.
  3. Print the text you read to the console/log/
  4. Print an easy to find string in the log directly before requiring the file.
  5. Require the file with patcher.

When the require call fails, check to the last ‘easy to find string’ and then look at the prior dump of the downloaded file.

This will show you if the file is corrupted.

Clean Install versus Dowloaded Scripts
You said this:

The data of the APP before deletion is exactly the same as that of the reinstalled APP.

Do you mean ‘The SCRIPT of the APP before deletion is exactly the same as that of the reinstalled APP.’

If so, then that isn’t right. During a clean install first run, you are using the script that came with the app in the resource directory area.

After downloading a script and using patcher, it comes from the documents folder.

1 Like

Also, your usage looks correct.

Google (and I assume Apple) dislike dynamic script loading and will ban your app if they find it. They did that to all apps using Vungle because of this a short while ago

1 Like

@roaminggamer

I mean is that every time enter the game, I will check the S3 data.

They are all through the download. I am pretty sure they are in the documents folder.

However, the problem has only occurred once!

I re-run the application install in my phone for more than 20 times, during which only once problem occurred.

I did not find any abnormality in the console, I will continue to check whether the transmission process is damaged.

I mainly want to determine whether the usage is correct or not.

Thank you for your clarification so that I can rule out this problem. :grinning:

@anon63346430

This is really terrible news.

Google can only upload files within 100MB, and 100MB is not in line with today’s Full HD games.

Most games use external transmission.

If Google prohibits this practice, the top 100 in the play store rankings will disappear. :joy:

Downloading assets remotely is absolutely fine. downloading lua scripts which change functionality is a very dodgy area.

After all your simple word game (as an example) could become something much more malicious!

1 Like

That is to say, Google only focuses on the files that “affect the function”, otherwise, the image tables packaged with Texture Packer will also have Lua, and there is no way to avoid the transmission of Lua.

I play many large online mobile games, and their practice is that there will be a big update every month, which can only be updated from the play store.

The files updated every week are transmitted remotely.

So will this be a good way to circumvent the rules set by Google?