Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-18631] Android: AlertDialog.show() causes crash

GitHub Issuen/a
TypeBug
PriorityHigh
StatusResolved
ResolutionCannot Reproduce
Resolution Date2015-03-12T22:12:41.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
ReporterLeor Brenman
AssigneeHieu Pham
Created2015-03-03T00:19:13.000+0000
Updated2016-02-12T19:15:49.000+0000

Description

AlertDIalog show() causes crash on Android but OK on iOS I have a demo app that i am creating and want to show() and AlertDialog on a button click to confirm the user's action. I am following the code example in the online docs and it works fine on iOS. On Android it will work once or twice and then on the 3rd or fourth time, it causes a fatal crash (logs attached). Ricardo has the project and can help anyone in Mountain View. TEST ACCOUNT LOGIN: username: a password: 1234 When I use the same code in a simpler Hello World app it works fine on iOS and Android.

Attachments

FileDateSize
addApproval_fixed.zip2015-03-12T01:44:52.000+00002481
logcat.rtf2015-03-03T00:19:13.000+000024582

Comments

  1. Ingo Muschenetz 2015-03-03

    [~ralcocer] Can we extract this out into a test case to attach to the ticket?
  2. Ricardo Alcocer 2015-03-03

    Leor created a minimalist test case but it's not giving any errors. It appears to be a combination of factors, but the patterns [~lbrenman] is using are not really unusual. I suppose I could post the whole project for review, if [~lbrenman] is fine with that.
  3. Leor Brenman 2015-03-03

    I am fine with that :)
  4. Ricardo Alcocer 2015-03-03

    The project has modules and whatnot, so it exceeds the size allowed by Jira, but can be downloaded from : http://sht.tl/iS9rrP . [~lbrenman] created a test user "a" with password "1234".
  5. Pedro Enrique 2015-03-11

    I've looked at the code but not tested it yet. You are creating an AlertDialog in the XML and showing it later. The AlertDialog is not meant to be used like that, it's meant to be created, shown, and garbage collected. Try creating the alert in code and showing it as soon as it's created. Create one instance per "show" that you need. They're not meant to be recycled.
  6. Leor Brenman 2015-03-11

    That will be great if this is the case and i will check this out. However, i copied this code directly from our API docs at: http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.AlertDialog Are the docs wrong or did i misinterpret the docs?
  7. Leor Brenman 2015-03-12

    Your suggestion worked!! Thanks. I think we need to convert this to a document JIRA because the documentation does not clearly explain this and implies that you can implement via XML and js. If you agree can you convert this to a documentation bug or i can, but will defer to your advice.
  8. Leor Brenman 2015-03-12

    Fixed controller with Pedro's suggested fix
  9. Hieu Pham 2015-03-12

    Unable to reproduce with this test case
       var win = Ti.UI.createWindow();
           var btn = Ti.UI.createButton({
               title:'click me now!'
           });
           win.add(btn);
           var myAlert = Ti.UI.createAlertDialog({
               title: 'alert',
               message: 'Alert',
               buttonNames: ['ok']
           });
           btn.addEventListener('click', function(){
               myAlert.show();
           });
           win.open();
       
  10. Hieu Pham 2015-03-12

    I analyzed the log and there wasn't any log indicating a crashing error from Titanium that is app related. Since I can't reproduce this issue, I'll resolve it. Please feel free to reopen if you have more information, though it looks like your problem is solved.
  11. Abdiel Aviles 2016-02-12

    Pedro Enrique, I'm extremely confused here. Are we supposed to use it with XML or not? You state we are not supposed to, but as Leor Brenman says, the documentation even gives an example of how to use it with XML. Looks like I'm also getting this crash on devices with low memory.

JSON Source