问题
I have this simple line of code that works perfectly on the simulator but gets a nil
on a actual android device:
local path = system.pathForFile( nil, system.ResourceDirectory)
print('path', path)
path = path .. "/assets/audios"
on the android device I get Runtime Error .......attempt to concatenate local 'path' (a nil value)
I read the the android docs and it says you don't need permission to read the internal storage.
What's causing this error? How to solve it?
Do I need to add any special permissions to use pathForFile
in android?
回答1:
Ok..found something that works not the android device. It is bit of a cheat/workaround...but as long as it works....
so this does not work on the device but works on the simulator:
local path = system.pathForFile( nil, system.ResourceDirectory)
print('path', path)
path = path .. "/assets/audios"
This however works which will get you the same result just through different steps:
local path = system.pathForFile('assets/audios/x.wav', system.ResourceDirectory)
-- path = path .. "/assets/audios"
path = string.gsub( path, 'x.wav', '' )
来源:https://stackoverflow.com/questions/34633040/corona-works-on-simulator-but-not-on-real-android-device-system-pathforfile