WARNING: Failed to find image

I wish to load separate images into a table row, Would someone explain why the indirect reference:

[lua]

local params = event.row.params

print( "params.img = "…params.insimage )  – OUTPUTS params.img = “NIA.PNG”

row.img = display.newImage( params.insimage )  --results in WARNING: Failed to find image(“NIA.PNG”)

[/lua]

Whereas

[lua]

row.img = display.newImage(“NIA.PNG”)

[/lua]

works fine, which means the file can be found.

Hi @davidafisher,

Are you testing on device or in the Corona Simulator? Windows or Mac? Is the file located in a subdirectory or something?

Thanks,

Brent

I had this problem to when I started with Corona. The main problem is either your image isn’t spelled correctly, it doesn’t have the correct capitalization, or it is located in a folder.

Check all those things.

If your picture is in a folder then

here is an example of what you should do

local rowImage   rowImage = display.newImage("imageFolder/image.png")

I’m running the Corona simulator Build: 2014.2189 Starter on Windows 8. Although I have an images sub-directory which works fine for locating and setting background images to my composer scenes, in total frustration I place a copy of the image file in the main directory and all sub-directories.

I’ve been that rout with the spelling, capitals, image folder etc. if it was incorrect I would be able to have the code work when referencing the file directly - as in my code example above. (cut and paste ensures the same spelling. I’m wondering if its a graphics issue and the Starter package doesn’t support that capability

Hi @davidafisher,

There may be an issue with the reference in Lua (Starter supports all core graphics features, so it’s not an issue there). Can you show exactly (in code) where you assign this property to the tableView params, and possibly post a screenshot of your console output which shows the print() output from the first code block you posted in this thread?

Thanks,

Brent

Here is the code where the params get set.

local i = 1

local myData = {}

for Hatch in insects:nrows(sqlHatched) do

if (latin == true) then
myData[i] =
{
rowtitle = Hatch.OrdName …" " … Hatch.FamilyName,
rowsubtitle = Hatch.Genus …" “… Hatch.Species,
rowinsimage = Hatch.GenAdImg
}
else
myData[i] =
{
rowtitle = Hatch.FamilyName…” " … Hatch.Genus,
rowsubtitle = Hatch.OrdDesc …" - " … Hatch.DunPattern,
rowinsimage = Hatch.GenAdImg
}
end
i= i + 1
end

–had to do this outside the for loop because of a tail call error
local tableEmerge = widget.newTableView (tableEmergeOptions)
for i = 1, #myData do
tableEmerge:insertRow
{
isCategory = false,
rowHeight = 80,
params =
{
title = myData[i].rowtitle,
subtitle = myData[i].rowsubtitle,
– insimage = ‘"images/’…myData[i].rowinsimage…’"’
insimage = ‘"’…string.upper(myData[i].rowinsimage)…’"’
}
}
end
 

PLEASE note the commented line where I’ve tried various string alternatives

HERES the Error

params.img = “NIA.PNG”
WARNING: Failed to find image(“NIA.PNG”)
Runtime error
c:\users\david fisher\documents\corona projects\hatchingthematch\db\main.lua:149: attempt to index field ‘img’ (a nil value)
stack traceback:
c:\users\david fisher\documents\corona projects\hatchingthematch\db\main.lua:149: in function ‘_onRowRender’
?: in function ‘_createRow’
?: in function <?:1116>
(tail call): ?
c:\users\david fisher\documents\corona projects\hatchingthematch\db\main.lua:230: in function ‘fetchEmerge’

AND Here’s the code in the onRowRender function that causes the error

142 local params = event.row.params
143 if ( event.row.params ) then
144 print( "params.img = "…params.insimage )
145 print( "params.title = "…params.title )
146 print( "params.subtitle = "…params.subtitle )
147 local rowgroup = display.newGroup( )
148 row.img = display.newImage( params.insimage )
149 row.img.x = math.floor(row.img.width*0.5 + 6)
150 row.img.y = math.floor(row.img.height*0.5)

hope thos is what you were requesting

Hi David,

I think you’re accidentally putting quotes around the string somewhere. If I just put this in a test project:

[lua]

display.newImage( “missing.png” )

[/lua]

Then I get this error message in the console:

WARNING: Failed to find image(missing.png)

But notice that you get this (if you copied and pasted it accurately):

WARNING: Failed to find image("NIA.PNG")

Notice that yours has quotes around it, so it’s looking for something like “NIA.PNG” with the quotes, not the file NIA.PNG.

I see some definite issues in how you’ve formatted – and how you’re concatenating – your strings. This is very likely the issue.

Best regards,

Brent

As Brent said, it should look more like this:

insimage = “images/” … myData[i].rowinsimage

Or

insimage = string.upper(myData[i].rowinsimage)

I found the problem. I’m building this scene in a sub-directory before adding as a composer scene to the rest of my app in the primary folder. So Corona uses that sub-directory as the baseDirectory and my images are loaded under the primary folder where I have all my scenes. In other word I have to temporarily redirect my path for the images to be loaded. thanks for your support

Hi @davidafisher,

Are you testing on device or in the Corona Simulator? Windows or Mac? Is the file located in a subdirectory or something?

Thanks,

Brent

I had this problem to when I started with Corona. The main problem is either your image isn’t spelled correctly, it doesn’t have the correct capitalization, or it is located in a folder.

Check all those things.

If your picture is in a folder then

here is an example of what you should do

local rowImage &nbsp; rowImage = display.newImage("imageFolder/image.png")

I’m running the Corona simulator Build: 2014.2189 Starter on Windows 8. Although I have an images sub-directory which works fine for locating and setting background images to my composer scenes, in total frustration I place a copy of the image file in the main directory and all sub-directories.

I’ve been that rout with the spelling, capitals, image folder etc. if it was incorrect I would be able to have the code work when referencing the file directly - as in my code example above. (cut and paste ensures the same spelling. I’m wondering if its a graphics issue and the Starter package doesn’t support that capability

Hi @davidafisher,

There may be an issue with the reference in Lua (Starter supports all core graphics features, so it’s not an issue there). Can you show exactly (in code) where you assign this property to the tableView params, and possibly post a screenshot of your console output which shows the print() output from the first code block you posted in this thread?

Thanks,

Brent

Here is the code where the params get set.

local i = 1

local myData = {}

for Hatch in insects:nrows(sqlHatched) do

if (latin == true) then
myData[i] =
{
rowtitle = Hatch.OrdName …" " … Hatch.FamilyName,
rowsubtitle = Hatch.Genus …" “… Hatch.Species,
rowinsimage = Hatch.GenAdImg
}
else
myData[i] =
{
rowtitle = Hatch.FamilyName…” " … Hatch.Genus,
rowsubtitle = Hatch.OrdDesc …" - " … Hatch.DunPattern,
rowinsimage = Hatch.GenAdImg
}
end
i= i + 1
end

–had to do this outside the for loop because of a tail call error
local tableEmerge = widget.newTableView (tableEmergeOptions)
for i = 1, #myData do
tableEmerge:insertRow
{
isCategory = false,
rowHeight = 80,
params =
{
title = myData[i].rowtitle,
subtitle = myData[i].rowsubtitle,
– insimage = ‘"images/’…myData[i].rowinsimage…’"’
insimage = ‘"’…string.upper(myData[i].rowinsimage)…’"’
}
}
end
 

PLEASE note the commented line where I’ve tried various string alternatives

HERES the Error

params.img = “NIA.PNG”
WARNING: Failed to find image(“NIA.PNG”)
Runtime error
c:\users\david fisher\documents\corona projects\hatchingthematch\db\main.lua:149: attempt to index field ‘img’ (a nil value)
stack traceback:
c:\users\david fisher\documents\corona projects\hatchingthematch\db\main.lua:149: in function ‘_onRowRender’
?: in function ‘_createRow’
?: in function <?:1116>
(tail call): ?
c:\users\david fisher\documents\corona projects\hatchingthematch\db\main.lua:230: in function ‘fetchEmerge’

AND Here’s the code in the onRowRender function that causes the error

142 local params = event.row.params
143 if ( event.row.params ) then
144 print( "params.img = "…params.insimage )
145 print( "params.title = "…params.title )
146 print( "params.subtitle = "…params.subtitle )
147 local rowgroup = display.newGroup( )
148 row.img = display.newImage( params.insimage )
149 row.img.x = math.floor(row.img.width*0.5 + 6)
150 row.img.y = math.floor(row.img.height*0.5)

hope thos is what you were requesting

Hi David,

I think you’re accidentally putting quotes around the string somewhere. If I just put this in a test project:

[lua]

display.newImage( “missing.png” )

[/lua]

Then I get this error message in the console:

WARNING: Failed to find image(missing.png)

But notice that you get this (if you copied and pasted it accurately):

WARNING: Failed to find image("NIA.PNG")

Notice that yours has quotes around it, so it’s looking for something like “NIA.PNG” with the quotes, not the file NIA.PNG.

I see some definite issues in how you’ve formatted – and how you’re concatenating – your strings. This is very likely the issue.

Best regards,

Brent

As Brent said, it should look more like this:

insimage = “images/” … myData[i].rowinsimage

Or

insimage = string.upper(myData[i].rowinsimage)

I found the problem. I’m building this scene in a sub-directory before adding as a composer scene to the rest of my app in the primary folder. So Corona uses that sub-directory as the baseDirectory and my images are loaded under the primary folder where I have all my scenes. In other word I have to temporarily redirect my path for the images to be loaded. thanks for your support

I am working with the same approach as yours, i.e. scenes in a sub-directory and images in sub-directory. It works without any problem in simulator. The android build also goes well. While testing the apk in android device, I see no images at all, but just a black space placeholders. I would appreciate if you have already found a solution to that? Please share your idea.