Runtime error corona应用程序的运行时错误

Runtime error corona应用程序的运行时错误,runtime-error,apk,coronasdk,Runtime Error,Apk,Coronasdk,我制作了一个非常简单的应用程序,具有一些简单的功能,它在corona模拟器上运行得非常好,如屏幕截图所示,但当我构建APK文件时,我在手机上打开应用程序时出现了以下错误:“c:\Users\Moamen\Documents\corona projects\Learning\main.lua:36:尝试索引全局“an”(一个零值) 这是应用程序错误: 电晕模拟器上应用程序的照片: 这就是 代码: Android区分大小写,但Windows(通常)不区分大小写。因此,将bg.JPG替换为bg.J

我制作了一个非常简单的应用程序,具有一些简单的功能,它在corona模拟器上运行得非常好,如屏幕截图所示,但当我构建APK文件时,我在手机上打开应用程序时出现了以下错误:“c:\Users\Moamen\Documents\corona projects\Learning\main.lua:36:尝试索引全局“an”(一个零值)

这是应用程序错误:

电晕模拟器上应用程序的照片:

这就是

代码:


Android区分大小写,但Windows(通常)不区分大小写。因此,将
bg.JPG
替换为
bg.JPG
,并相应地重命名文件

注:

  • 使用小写字母作为文件名
  • 尽可能使用局部变量,例如
    local an=display.newImage(“bg.jpg”,150250)

欢迎使用堆栈溢出!请添加图像而不是链接。这一次我已经为您完成了这项工作-请参阅以获取有关格式设置的更多信息。
-----------------------------------------------------------------------------------------
--
-- main.lua
--
-----------------------------------------------------------------------------------------

-- Your code here
sound = audio.loadStream( "test2.mp3" )
ssound = audio.loadSound( "test.wav")
function com( )
    audio.play( ssound )
    audio.setVolume( .5)
     --body
end
local options={duration = 10000 , onComplete = com }
audio.play( sound )
audio.setVolume( .25  )
group = display.newGroup()

function Puse( event)
    if ("began" == event.phase) then
        audio.pause()
    end
    -- body
end
function Resume( event)
    if ("began" == event.phase) then
        audio.resume(  )
    end
     --body
end
--local widget = require("widget")
--widget.setTheme( "widget_theme_ios" )

an = display.newImage( "bg.JPG" ,150,250 )
an.xScale = .3
an.yScale = .7
--aa = display.newImageRect("bg2.JPG",100,100)
--aa.x=160
--aa.y=230
text1 =display.newText({text= "TechForm" , x=455 , y= 1 , fontSize=("60")})
transition.to( text1, {x=150,y=1,time =2000} )
text2=display.newText({text= "The android app that made by " , x=455 , y= 70 , fontSize=("20")})
transition.to( text2, {x=160,y=70,time =4000} )

text3=display.newText({text= "Moamen Hassaballah " , x=460 , y= 120 , fontSize=("30")})
transition.to( text3, {x=160,y=120,time =5000} )

--display.newImage("ando.png",160 ,350)
--display.newCircle( 300, 300, 10 )
rect = display.newRect( 170, 475, 400, 100 )
rect:setFillColor(.117,.244,.244)
ttext=display.newText({text="Thanks for using our app", x=150, y=470 ,fontSize=25} )
--rect:removeSelf( )

function Touching( event)
    if ("began" == event.phase) then
        x=math.random( .1,.9 )
        y=math.random( .1,.9 )
        z=math.random( .1,.9 )
        rect:setFillColor( x,y,z )
    end
end
rect2=display.newRect(  70, 387, 125, 23 )

rect:addEventListener( "touch", Touching )
button = display.newImage("button.png",60,334)
button.xScale=.4
button.yScale=.4

function ch_color( event)
    if ("began" == event.phase) then
        x=math.random( .1,.9 )
        y=math.random( .1,.9 )
        z=math.random( .1,.9 )
        text3:setFillColor( x,y,z )
    end
end
rect2:addEventListener( "touch", ch_color )

local widget = require("widget")
widget.setTheme( "widget_theme_ios" )
function login(event)
    if ("began" == event.phase) then

        rect:removeSelf( )
        function login2( event)
            if ("began" == event.phase) then
                rect = display.newRect( 170, 475, 400, 100 )
                rect:setFillColor(.117,.244,.244)
                rect:addEventListener( "touch", Touching )
                ttext:toFront( )
                btn = widget.newButton{top=365,left=150 , label="Login" , onEvent=login}
                btn.xScale=.8
                btn.yScale=.7
            end

            -- body
        end
        btn =  widget.newButton{top=365,left=150 , label="Login" , onEvent=login2}
        btn.xScale=.8
        btn.yScale=.7

    end
    -- body
end
local btn = widget.newButton{top=365,left=150 , label="Login" , onEvent=login}
btn.xScale=.8
btn.yScale=.7
local bb = widget.newButton{ label = "Puse" , top = 250 , left = 150 ,onEvent=Puse}
bb.xScale=.8
bb.yScale=.7
local bb2 = widget.newButton{ label = "Resume" , top = 250 , left = 2 ,onEvent=Resume }
bb2.xScale=.8
bb2.yScale=.7
function handleTabBarEvent(event)
    if event.phase == "press" then
        print ("Tab " .. event.target._id .. " is selected")
        transition.to( cc, {x= -160 , y=220 , time=200} )
    end
end
cc = display.newText(  {text = "Shows Tap is selected" , x=-160 , y=220, fontSize = 30} )
function shows(event )
    if (event.phase=="press") then
        print( "shows tap is selected" )
        transition.to( cc, {x= 160 , y=220 , time=400} )
    end
    -- body
end

-- Configure the tab buttons to appear within the bar


local progressView = widget.newProgressView
{
    left = 10,
    top = 320,
    width = 300,
    isAnimated = true
}

-- Set the progress to 50%
function progress_to_0(event)
    if event.phase=="press"then
        xx = math.random( 0.1 , 0.9 )
        progressView:setProgress( 0.1 )
        transition.to( cc, {x= -160 , y=220 , time=200} )
    end 
end

function progress_to_25(event)
    if event.phase=="press"then
        progressView:setProgress( 0.25 )
        transition.to( cc, {x= -160 , y=220 , time=200} )
    end 
end
function progress_to_75(event)
    if event.phase=="press"then
        progressView:setProgress( 0.75 )
        transition.to( cc, {x= -160 , y=220 , time=200} )
    end 
end
function progress_to_1(event)
    if event.phase=="press"then
        progressView:setProgress( 1 )
        print( "shows tap is selected" )
        transition.to( cc, {x= 160 , y=220 , time=400} )
    end 
end

local tabButtons = {
    {
        label = "Tab1", -- Text of the label
        selected = true, -- Default selection
        size = 16, -- size of the font in the Tab
        onPress = progress_to_0 -- listener attached to the Tab
    },
    {
        label = "Tab2", -- Text of the label
        size = 16, -- size of the font in the Tab
        onPress = progress_to_25 -- listener attached to the Tab
    },
    {
        label = "Tab3", -- Text of the label
        size = 16, -- size of the font in the Tab
        onPress = progress_to_75
         -- listener attached to the Tab
    },{label="Shows" , size=16, onPress=progress_to_1 }
}

-- Create the Tabs object

local testTabs = widget.newTabBar
{
    top = -45,
    width = display.contentWidth,
    height = 70,
    buttons = tabButtons,
}