Few days ago I published my first Android app and I wish to thank all the great people on the forum who helped me with my questions. I also wish to ask for a last help (I hope) about this project. It is a little and fun game similar to Memory but it is not with images but with sounds. Its name is Vox Populi and you can found it on Google Play
https://play.google.com/store/apps/details?id=com.geppoz.voxpopuli&hl=it
If you wish you can see a video about how Vox Populi works going to
http://youtu.be/JgKIe1cbafo
This app is for italian audience so excuse me if you will not understand what I wrote. In a nutshell in Vox Populi there is a keyboard with 12 buttons. Every button, when pressed, reproduces a voice. There are 6 pairs of voices and the player must found them as soon as. Now, the great problem is that sometimes randomly the app crashes when a button is pressed with this error:
Unfortunately Vox Populi has stopped.The bad thing is that, as I wrote, the issue is absolutely random: it can happen when I press on a button the first time or when I press on a button after various games or can never happen!!! This is the code about creation of buttons:
for(i=0; i<numPulsanti; i++){ pulsante[i] = Ti.UI.createImageView({ nomePulsante: i, borderWidth: 1, borderColor: '#000', image: 'img/pulsante.jpg', width: parseInt(viewPulsantiera.getWidth() / 4), height: parseInt(viewPulsantiera.getHeight() / 4), suono: pathAudio + String(arrNumeriCasuali[i]) + '.mp3', opacity: 1, }); pulsante[i].addEventListener('click', verificaCoppia); viewPulsantiera.add(pulsante[i]); };this is the verificaCoppia function (verificaCoppia means 'Check pair') that is called when a button is pressed:
function verificaCoppia(){ sceltaFatta.numero++; numeroDiMosse++; if(sceltaFatta.numero==1){ this.borderColor = '#f00'; this.borderWidth = 4; sceltaFatta.suono = this.suono; sceltaFatta.nomePulsante = this.nomePulsante; effettoSonoro(this); } else if(sceltaFatta.numero==2){ pulsante[sceltaFatta.nomePulsante].borderColor = '#000'; pulsante[sceltaFatta.nomePulsante].borderWidth = 1; sceltaFatta.numero = 0; effettoSonoro(this); if(sceltaFatta.suono==this.suono && sceltaFatta.nomePulsante!=this.nomePulsante){ this.setOpacity(0.3); pulsante[sceltaFatta.nomePulsante].setOpacity(0.3); this.touchEnabled = false; pulsante[sceltaFatta.nomePulsante].touchEnabled = false; coppieMancanti--; if(coppieMancanti==0) { imgViewFotoPersonaggio.opacity = 0.5; imgViewTimbro.visible = true; effettoSonoro('casoArchiviato.mp3'); clearInterval(idSetInterval); gestisciPulsantiera('distruggi'); creaMenuFineGioco(secondiPassati); }; }; }; };and this is the creation of sound object and the function called to reproduce the voice:
var effetto = Ti.Media.createSound({}); function effettoSonoro(obj){ effetto.reset(); effetto.release(); Ti.API.info(effetto.state); if(obj=='casoArchiviato.mp3'){ effetto.url = 'audio/' + obj; effetto.play(); } else{ effetto.url = obj.suono; effetto.play(); }; };I tried to use 'preload:true' into sound object. I tried to remove reset and release or to move them in another part of the code. I tried a lot of things but error is still there!
In Titanium console I catched this log when error occours:
[WARN] : dalvikvm: threadid=17: thread exiting with uncaught exception (group=0x40015560) [ERROR] : TiApplication: (Timer-31) [31313,469145] Sending event: exception on thread: Timer-31 msg:java.lang.IllegalStateException; Titanium 3.2.2,2014/03/05 12:22,96e9a07 [ERROR] : TiApplication: java.lang.IllegalStateException [ERROR] : TiApplication: at android.media.MediaPlayer.isPlaying(Native Method) [ERROR] : TiApplication: at ti.modules.titanium.media.TiSound$2.run(TiSound.java:516) [ERROR] : TiApplication: at java.util.Timer$TimerImpl.run(Timer.java:284) [ERROR] : AndroidRuntime: FATAL EXCEPTION: Timer-31 [ERROR] : AndroidRuntime: java.lang.IllegalStateException [ERROR] : AndroidRuntime: at android.media.MediaPlayer.isPlaying(Native Method) [ERROR] : AndroidRuntime: at ti.modules.titanium.media.TiSound$2.run(TiSound.java:516) [ERROR] : AndroidRuntime: at java.util.Timer$TimerImpl.run(Timer.java:284)and in Google Play admin console I got this:
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** Build fingerprint: 'samsung/m0xx/m0:4.3/JSS15J/I9300XXUGNA5:user/release-keys' Revision: '12' pid: 14181, tid: 14197, name: KrollRuntimeThr >>> com.geppoz.voxpopuli <<< signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0000000c r0 00000000 r1 80000000 r2 5fa08091 r3 00000001 r4 00000000 r5 5f311990 r6 00000000 r7 5f31199c r8 00002abc r9 5f45c479 sl 5f8e1f34 fp 6869e209 ip 5f8de30c sp 5f311920 lr 5f3eb5a7 pc 5f3eb398 cpsr 20000030 d0 4079800000000000 d1 4077c6b699f5423d d2 0000000000000000 d3 0000000000000005 d4 000000000000000a d5 40268b3f65200000 d6 41cdcd6500000000 d7 4077c6b699f5423d d8 4130000000000000 d9 0000000000000000 d10 0000000000000000 d11 0000000000000000 d12 0000000000000000 d13 0000000000000000 d14 0000000000000000 d15 0000000000000000 d16 3ff0000000000000 d17 0000000000000000 d18 412e848000000000 d19 40f86a0000000000 d20 40f86a0000000000 d21 3ff0000000000000 d22 4008000000000000 d23 4024000000000000 d24 4000000000000000 d25 547d42aea2879f2e d26 40026bb1bbb55516 d27 4024000000000000 d28 fffffffffffffffe d29 fffffffffffffffe d30 4018000000000000 d31 4000000000000000 scr 80000010 backtrace: #00 pc 00078398 /data/app-lib/com.geppoz.voxpopuli-1/libkroll-v8.so (titanium::EventEmitter::~EventEmitter()+75) #01 pc 000785a3 /data/app-lib/com.geppoz.voxpopuli-1/libkroll-v8.so (titanium::JavaObject::getJavaObject()+62) #02 pc 000e94c7 /data/app-lib/com.geppoz.voxpopuli-1/libkroll-v8.so (titanium::media::SoundProxy::reset(v8::Arguments const&)+78) #03 pc 00172490 /data/app-lib/com.geppoz.voxpopuli-1/libkroll-v8.so #04 pc 0005f650 <unknown> code around pc: 5f3eb378 d0012800 ef98f0d1 60632300 f7ff1c20 5f3eb388 1c20eb04 46c0bd70 004f2ec8 00001514 5f3eb398 1c0368c2 d0012a00 47707d18 20016902 5f3eb3a8 d1f92a00 46c0e7f9 1c04b510 29002000 5f3eb3b8 1c08d002 ec56f0e8 21006060 f0d61c22 5f3eb3c8 bd10e84c 1c04b570 f974f000 447b4b0d 5f3eb3d8 781d681b d0102d00 2b007d23 6803d106 5f3eb3e8 6d9b68e1 23004798 bd7060e3 23e36802 5f3eb3f8 68e1009b 479858d3 6920e7f5 f92af005 5f3eb408 e7f26125 004f4982 4d15b570 1c044b15 5f3eb418 58eb447d 60033308 2b0068c3 1c20d01c 5f3eb428 ffd0f7ff 68604b10 330858eb 28006023 5f3eb438 f0d1d010 6865eff0 eceef0de 1c022100 5f3eb448 f0dc1c28 6860ef3c d0012800 ef2cf0d1 5f3eb458 60632300 bd701c20 2b006903 e7e1dcdf 5f3eb468 004f2e04 00000a3c 00001514 1c04b570 code around lr: 5f3eb584 23004a12 68607523 1c21447a ef6cf0d1 5f3eb594 6900e003 f814f005 1c281c05 f7ffbd70 5f3eb5a4 2800fef9 68e5d101 1c20e7f7 f7ff2100 5f3eb5b4 68e5ffc1 4906e7f1 20064a06 447a4479 5f3eb5c4 ea5cf7ff 46c0e7dc 004f47ee ffffff51 5f3eb5d4 003da8dc 003da8e6 2200b510 1c044b09 5f3eb5e4 60826042 447b4808 581860e2 75226122 5f3eb5f4 60203008 d0022900 f7ff1c20 1c20ff9b 5f3eb604 46c0bd10 004f2c32 00000a3c 2200b510 5f3eb614 1c044b09 60826042 447b4808 581860e2 5f3eb624 75226122 60203008 d0022900 f7ff1c20 5f3eb634 1c20ff81 46c0bd10 004f2bfe 00000a3c 5f3eb644 4d15b570 1c044b15 58eb447d 60033308 5f3eb654 2b0068c3 1c20d01c feb6f7ff 68604b10 5f3eb664 330858eb 28006023 f0d1d010 6865eed6 5f3eb674 ebd4f0de 1c022100 f0dc1c28 6860ee22 ********************************************************************and this:
java.lang.IllegalStateException at android.media.MediaPlayer.isPlaying(Native Method) at ti.modules.titanium.media.TiSound$2.run(TiSound.java:516) at java.util.Timer$TimerImpl.run(Timer.java:284)I hope that it will be possible to solve this issue. I wish to thank all of you in advance for your help on this post.