Runtime error on Android, but not in simulator

Hi.

I just start developing my app, but I can’t run it on my android phone.

I getting a runtime error: 

…\main.lua:22:

ERROR: table expected. If this is a function call, you might have used ‘.’ instead of ':'

The line is: 

physics1.addBody( g1, "dynamic" )

And it worked properly on corona simulator, but not on android.

Is it a bug?

Thanks.

what is physics1 ?

Just a variable, I renamed it to check for typo.

I take code from example in documentation.

local physics1 = require( "physics" ) physics1.start()  ... local g1 = display.newImage(...) ... physics1.addBody( g1, "dynamic" )

Post your full code

here it is:

local physics1 = require( "physics" ) physics1.start()  local img1 = display.newImage(       "Icon-152.png",       display.contentCenterX,       display.contentCenterY+250)      local g1 = display.newImage(       "Icon-40.png",       display.contentCenterX,       display.contentCenterY+249)      local g2 = display.newImage(       "Icon-40.png",       display.contentCenterX,       display.contentCenterY+249) physics1.addBody( g1, "dynamic" ) physics1.addBody( g2, "dynamic" ) g1.gravityScale = 0 g2.gravityScale = 0 local color = 1 local action = function()     img1:setFillColor( 0, 0, color )     g1.gravityScale = 1     g2.gravityScale = 1     g1:applyLinearImpulse( -1.5, -140, g1.x, g1.y )     g2:applyLinearImpulse( -1, -10, g2.x, g2.y ) end img1:addEventListener("tap", action)

That works fine

Are you seeing any warnings in your console log about possible file name case-sensitivity issues?

When you run it on your device can use use “adb logcat” to look for errors and report them here?

Keep in mind Android and iOS are case sensitive operating systems while macOS and Windows are not.

Rob

  1. no any warnings in console log

  2. I can’t use adb to check 

App starting, showing Corona Labs Logo, and then runtime error.

This resuting apk:

https://www.dropbox.com/s/bmwr3qtmyvr6se6/hbm.apk?dl=0

Screens:

Alcatel Pixie 3:

https://www.dropbox.com/s/mv8jy8ge6hjxtzq/20170704_195713.jpg?dl=0

Samsung:

https://www.dropbox.com/s/jco61kmxqqoi0hj/IMG_20170704_195509.jpg?dl=0

just before line 22 add this…

if g1 == nil then display.newRect(display.contentCenterX, display.contentCenterY, 1000, 1000).fill = {1,0,0} end

…and tell us if the screen goes red

Screen red!

And runtime error on the same line.

Then - as Rob hinted at - your problem is case-sensitivity on your filenames or those files are not being included in your build

I got it.

It is, obviously, my mistake.

I have used first seeing image for prototyping. And it was not included in apk, because in build.settings listed in excludeFiles  for android. 

(But now, I wish to see warnings for mistakes like this)

Thanks to everybody.

I love that you mark your answer as “best answer” when I told you what the answer was!  *SMH*

I am new on this forum, I suppose it mark all topic. 

I’m curious as to why you can’t use “adb logcat”? This is a critical tool in being able to debug problems on the device. If you need help with it, please see:

https://docs.coronalabs.com/guide/basics/debugging/index.html

Rob

It problem with my devices and drivers, but not with Corona SDK, thanks for caring ;-) 

what is physics1 ?

Just a variable, I renamed it to check for typo.

I take code from example in documentation.

local physics1 = require( "physics" ) physics1.start()  ... local g1 = display.newImage(...) ... physics1.addBody( g1, "dynamic" )

Post your full code

here it is:

local physics1 = require( "physics" ) physics1.start()  local img1 = display.newImage(       "Icon-152.png",       display.contentCenterX,       display.contentCenterY+250)      local g1 = display.newImage(       "Icon-40.png",       display.contentCenterX,       display.contentCenterY+249)      local g2 = display.newImage(       "Icon-40.png",       display.contentCenterX,       display.contentCenterY+249) physics1.addBody( g1, "dynamic" ) physics1.addBody( g2, "dynamic" ) g1.gravityScale = 0 g2.gravityScale = 0 local color = 1 local action = function()     img1:setFillColor( 0, 0, color )     g1.gravityScale = 1     g2.gravityScale = 1     g1:applyLinearImpulse( -1.5, -140, g1.x, g1.y )     g2:applyLinearImpulse( -1, -10, g2.x, g2.y ) end img1:addEventListener("tap", action)