Runtime Error

I have problem with my application, when I start it in simulator everything is okay, I can build it without errors too. But when I run corona debugger I got this:

Backtrace: \*[ 1] (nil) at main.lua:1

Everytime, even if main.lua is empty. When I build app and install on my device I got runtime error while launching:

main.lua:5: attempt to index local 'avatar' (a nil value)

Here is main.lua:

local licensing = require("licensing") licensing.init("google") display.setStatusBar(display.HiddenStatusBar) local avatar = display.newImage("avatar.png") avatar.width = display.contentWidth / 3 avatar.height = display.contentHeight / 2 avatar.x = display.contentCenterX avatar.y = display.contentCenterY local signature = display.newText("RAKVASEN",display.contentCenterX,display.contentCenterY + (display.contentHeight / 2) / 2,"Next Custom",40) local function introlistener() display.remove(avatar) display.remove(signature) local composer = require("composer") composer.gotoScene("menu") end timer.performWithDelay(3000,introlistener)

Is your avatar.png file in the same directory as main.lua?

Yes.

Are you sure it’s a valid PNG file?  BTW: you can read the device’s console long and look for more errors there. Please read http://docs.coronalabs.com/guide/basics/debugging/index.html

Rob

Yes it is valid file, in console is only 2 warnings about hidden status bar and licensing not working in simulator. Here is the project:

https://drive.google.com/file/d/0B5mXvpjIbTorOU83cmJQaEVOUzQ/view?usp=sharing

What devices are you trying to run this on?

What version of Corona SDK are you using?

What OS are you using to build with?

Rob

I try to run it on LG Leon and Galaxy S3. I use latest corona sdk build. I build app on Windows 10 Home.

What OS are the devices running?

Rob

Android.

We’ve found the problem (Thanks Sergey and Perry!).

You have expansion files turned on in your build settings. For you to use that, you have to upload the apk and obb file to Google Play and then install it to your device from Google Play (as an Alpha or Beta).

But unless you need expansion files, I would turn this feature off.

Rob

That solves the problem, thank you.

I got same problem with another code:

local composer = require("composer") local scene = composer.newScene() function scene:create(event) local function downloadlistener() end network.download("https://lh3.googleusercontent.com/FfF38ylbEh2tyCAeOTVzbVhjdMmD6lpYhHn3-1jIcCN9VtLfCq2SzA4yaV6oSpx7\_ctvSIW1RrryeNwM0rwCzAbXvICJVWzHwLQYrp-uJf1va8f1pluJSE7Ri4KtRJnlbLkOQQYrbqQZZUL0su67tFP8Qc3v7ReEClEj793viOpwJvveJ7c3IGnaE9lJBtUlWoImcWufMJFaqoVyPauUK7ytW7VEVqXui-stlCDiynvHKw0DPrX2DjS7dbmiz3Fmq3AY3wboGqEAkz\_Q\_jflbJTvEowqTD3dmZGC9ORayTFT\_i5bzQCHk182AP9V9pu39znJ\_3-n9dBZIa5v1e5ekO9w\_JjglQ0dR\_MGrRpA2xxeaq-Z1ExzX-IVJWYasgYyx\_YdDaIjrJm2cV5oTeYrIA7yOooq3ET7SjfYEAMQWH80TAbY6gZzl0p2V-ut3RlYnpKESDuNlIahAgXMMEMMEPB6TUd5xt1Zs7GDw3523y92Pi27XKlY-H7mEGKnNdTmkADSsNhHLVvCsXhuRnPw4LYL40\_QCxtDgahpxIMXypAAXRG6S4DY6w5GdsBAynWiDHE9=w1725-h970-no","GET",downloadlistener,"animals1.jpg",system.TemporaryDirectory) local animals1 = display.newImageRect("animals1.jpg",system.TemporaryDirectory,display.contentWidth / 2,display.contentHeight / 2) animals1.x = (display.contentWidth / 2) / 2 animals1.y = (display.contentHeight / 2) / 2 network.download("https://lh3.googleusercontent.com/mXbSzSZHgA0TtGPQuHs67wisixJD88CVsa8Lv\_UZ7Zy9rEVd02Z3atERhrNnoT6pLy9-A8GoS3PV2s2U3VTjYV9Zupjp7s9Lr0w6U2bCtN-kGHwK5sGwILvzTxizZCs4Okz69sBIfnw6jHnX5pAHxGwyjkD0RjCOp6Owso5Iq65nqBUGolxVb-NF7mleLDw9s1yEXRNxjpMmAPaLDk3vbV1XnA7fxRIx11RnmDU9G7YcYzfADe5vBjfmYfwD0prbbfepVZMx2FA2HEwXV79WLwNYD\_CC9oNI0Mwv3GDYPOzJH5HxIDYoz\_R4oDlV5ONcKpEY7dNU-6fV7JknLRy87yeCZVxQdpgEs88vMC6B9UUx5yeaRvbLyOWiDkT8H7AbRns17Jp8RGIGYHsm-KUIOz\_k\_xhCQXHAnJYLvMmLPJDzq8qcaVlpOd-4mZTG0WCbqxsPBmpD7\_Y40DzbRc\_GzOHecqX7gx-OCKB5U21TRYZikFqCjeoQAyINySIbnUigmeJb6PyaHdWtkMoZ-0C0\_4klakRUQEBczLq\_hFq59-ZDizuKLwhIopVMr00ulXaU4gJL=w958-h539-no","GET",downloadlistener,"nature1.jpg",system.TemporaryDirectory) local nature1 = display.newImageRect("nature1.jpg",system.TemporaryDirectory,display.contentWidth / 2,display.contentHeight / 2) nature1.x = display.contentWidth - (display.contentWidth / 2) / 2 nature1.y = (display.contentHeight / 2) / 2 local function animalstaplistener() end animals1:addEventListener("tap",animalstaplistener) local function naturetaplistener() end nature1:addEventListener("tap",naturetaplistener) end function scene:destroy(event) display.remove(animals1) display.remove(nature1) end scene:addEventListener("create",scene) scene:addEventListener("destroy",scene) return scene

Runtime Error

C:\Users\rakva\Documents\Corona Projects\Jigsaw Puzzle\menu.lua:8: attempt to index local ‘animals1’ (a nil value)

On LG Leon with Android.

You can’t access the image until it has been downloaded, in this use case.

You should initialize the display object in the network download listener

Works fine now, thank you.

Is your avatar.png file in the same directory as main.lua?

Yes.

Are you sure it’s a valid PNG file?  BTW: you can read the device’s console long and look for more errors there. Please read http://docs.coronalabs.com/guide/basics/debugging/index.html

Rob

Yes it is valid file, in console is only 2 warnings about hidden status bar and licensing not working in simulator. Here is the project:

https://drive.google.com/file/d/0B5mXvpjIbTorOU83cmJQaEVOUzQ/view?usp=sharing

What devices are you trying to run this on?

What version of Corona SDK are you using?

What OS are you using to build with?

Rob

I try to run it on LG Leon and Galaxy S3. I use latest corona sdk build. I build app on Windows 10 Home.