Phantom Error : Android

My app runs great on numerous Android devices, but on a Galaxy 10 tablet (GT-N8013 - v 4.1.2) I have been experiencing a silent crash. The app “settings” scene opens, but all controls are disable / unusable. The scene stays open for ~5 seconds and then closes.

My global exception handler and adb show nothing. The app simply closes and shows the “Unfortunately x has stopped” dialog after it is closed.

After commenting out every single control, I systematically tracked the cause down to one line.  Assigning text to a newTextField.  I’ve tried hardcoding string and number values and the assignment always causes a crash.

Again, this works on every other device that has been tested.  Is there a workaround for this?

[lua]


– AUTO VOL VAL


volValue = native.newTextField( switchLeft + 60, autoVol.y + 50, 65, 40 )

volValue.inputType = “number”

sceneGroup:insert( volValue )

if(autoVol.isOn) then

     autoVolText.isVisible = true

     volValue.isVisible = true

     if (glo.volumeLvl) then

         volValue.text = glo.volumeLvl — *** WHERE THE CRASH OCCURS

     end

else

     autoVolText.isVisible = false

     volValue.isVisible = false

end

[/lua]

I would remove the end in that statement…

if (glo.volumeLvl) then volValue.text = glo.volumeLvl else autoVolText.isVisible = false volValue.isVisible = false end

I’m not sure I follow, That’s a nested if statement. Removing the end would change the logic.

Oh, I see… the lack of indentation got me.  :smiley:

In that case, I would make sure that glo.volumeLvl is not nil and is a text type.

Check for nil and use tostring(glo.volumeLvl)

Yeah, apparently I don’t know how to indent on here. It always drops my formatting and left justifies.

I’ve confirmed and tried all of that.  I’ve replaced the glo.volumeLvl  with 75, “75”, and “”.  They all cause a crash. The only way to stop the crash on this particular device is to remove the assignment statement.

[lua]

volValue.text = glo.volumeLvl  (Crash)

volValue.text = “” (Crash)

volValue.text = 75 (Crash)

volValue.text = “75” (Crash)

[/lua]

 

If you type into the textfield manually, does it let you print the value of volValue.text? 

Also, what is the actual error message that appears in the console when this happens?

Touch doesn’t set focus to the text field. The scenes displays on the tablet, but all controls are disabled; or at least not usable. The scene will display for ~5 seconds and then it silently crashes. Nothing in ADB, no exceptions are caught, and no other messages until after the app closes.

Removing that one line allows everything to work as designed.

This might have been your first step, but have you tried signing it with a debug keystore and then testing? You’ll usually get more useful output than you will with a release keystore.

I haven’t tried that. I will now.  This also prevents the crash…

I did this to get the version info

 native.showAlert("version", system.getInfo( "androidAppVersionCode" ), {"ok"})

and changed the if statement to this…

[lua]

if (glo.volumeLvl) then

     if(system.getInfo( “androidAppVersionCode” ) ~= 65) then

          volValue.text = glo.volumeLvl — *** WHERE THE ERROR OCCURS

     end

end

[/lua]

If someone can tell me how to get indents to work I’ll fix my formatting :slight_smile:

You are using HTML style angle brackets around your “lua” and “/lua” tags. This system uses square brackets for that:

[lua]...[/lua]

You can also click on the blue <> button in the row with Bold & Italic and paste your code into the popup window.

Rob

I would remove the end in that statement…

if (glo.volumeLvl) then volValue.text = glo.volumeLvl else autoVolText.isVisible = false volValue.isVisible = false end

I’m not sure I follow, That’s a nested if statement. Removing the end would change the logic.

Oh, I see… the lack of indentation got me.  :smiley:

In that case, I would make sure that glo.volumeLvl is not nil and is a text type.

Check for nil and use tostring(glo.volumeLvl)

Yeah, apparently I don’t know how to indent on here. It always drops my formatting and left justifies.

I’ve confirmed and tried all of that.  I’ve replaced the glo.volumeLvl  with 75, “75”, and “”.  They all cause a crash. The only way to stop the crash on this particular device is to remove the assignment statement.

[lua]

volValue.text = glo.volumeLvl  (Crash)

volValue.text = “” (Crash)

volValue.text = 75 (Crash)

volValue.text = “75” (Crash)

[/lua]

 

If you type into the textfield manually, does it let you print the value of volValue.text? 

Also, what is the actual error message that appears in the console when this happens?

Touch doesn’t set focus to the text field. The scenes displays on the tablet, but all controls are disabled; or at least not usable. The scene will display for ~5 seconds and then it silently crashes. Nothing in ADB, no exceptions are caught, and no other messages until after the app closes.

Removing that one line allows everything to work as designed.

This might have been your first step, but have you tried signing it with a debug keystore and then testing? You’ll usually get more useful output than you will with a release keystore.

I haven’t tried that. I will now.  This also prevents the crash…

I did this to get the version info

&nbsp;native.showAlert("version", system.getInfo( "androidAppVersionCode" ), {"ok"})

and changed the if statement to this…

[lua]

if (glo.volumeLvl) then

     if(system.getInfo( “androidAppVersionCode” ) ~= 65) then

          volValue.text = glo.volumeLvl — *** WHERE THE ERROR OCCURS

     end

end

[/lua]

If someone can tell me how to get indents to work I’ll fix my formatting :slight_smile:

You are using HTML style angle brackets around your “lua” and “/lua” tags. This system uses square brackets for that:

[lua]...[/lua]

You can also click on the blue <> button in the row with Bold & Italic and paste your code into the popup window.

Rob