Arggh! it seems to be a random error, it just happned again a few
times. If I debug and step through it works fine. If i run normally it
fails.

 the code fails when builder.create().show(); is called on the
dialogue

Here's the snippets( i'm using the template pattern to build different
loading objects)

in the activity packbuilder is the xml loader, buildJamPacks is the
method i am updating

private void showWelcomeMessage(){
                if (mPackBuilder == null) {
                        mPackBuilder = new JamPackBuilderAssets(this);
                        mPackBuilder.buildJamPacks();
                }
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                //builder.setTitle("Please choose a loop pack");
                //builder.setIcon(R.drawable.alert_dialog_icon)
                builder.setTitle("Welcome to MicroJam!");
        builder.setMessage(R.string.instructions);
                builder.setPositiveButton("Ok", new 
DialogInterface.OnClickListener
() {
                        public void onClick(DialogInterface dialog, int 
whichButton) {

                                openJamPack(mPackBuilder.getPack(0));//default 
pack House 1
                        }
                });
                builder.create().show();
        }



//Working code:

// Loops through each folder in the root.
        // Load the song definition file for each song(default_song.xml)
        public void buildJamPacks() {
                mJamPacks = new ArrayList<JamPack>();
                File[] packs = new File(mRootFolder).listFiles();
                int l = packs.length;
                for (int i = 0; i < l; i++) {
                        File pack = packs[i];

                                File defaultSongFile = new 
File(pack.getAbsolutePath() + "/"
                                        + SONG_FILE_NAME);
                        if(defaultSongFile.exists()){
                                Document songXml = 
parseSongFile(defaultSongFile);
                                JamPack JamPack = 
buildPackFromXml(pack.getAbsolutePath(),
songXml);
                                mJamPacks.add(JamPack);
                        }else{

                                //TODO: handle this gracefully
                        }

                }
        }
 protected Document parseSongFile(File file) {
                try {
                        DocumentBuilder docBuilder = 
DocumentBuilderFactory.newInstance()
                                        .newDocumentBuilder();
                        InputStream fis = new FileInputStream(file);
                        Document songXml = docBuilder.parse(fis);
                        return songXml;
                } catch (FileNotFoundException e) {


//Not working code
public void buildJamPacks() {
                mJamPacks = new ArrayList<JamPack>();
                AssetManager manager = mCtx.getAssets();
                String[] packs;
                try {
                        packs = manager.list(mLoopsDir);
                        int l = packs.length;
                        for (int i = 0; i < l; i++) {
                                String pack = packs[i];
                                String fullpath = mLoopsDir + "/" + pack ;

                                Document songXml = parseSongAsset();
                                JamPack JamPack = buildPackFromXml(fullpath, 
songXml);
                                mJamPacks.add(JamPack);
                                songXml = null;

                        }
                }
                catch(IOException e){
                        e.printStackTrace();
                }
        }


protected Document parseSongAsset() {
        try {
                InputStream filestream = null;
                filestream = mCtx.getResources().openRawResource
(R.raw.default_song);
                DocumentBuilder docBuilder =
DocumentBuilderFactory.newInstance()
                                .newDocumentBuilder();
                Document songXml = docBuilder.parse(filestream);
                return songXml;
        } catch (FileNotFoundException e) {



Thanks, please help! this is driving me nuts ;)
Simon

On Aug 29, 3:15 pm, longhairedsi <longhaire...@googlemail.com> wrote:
> Ok i found the problem. But don't ask my why this would cause a
> problem, I have no idea!
>
> It stems from me passing the inputstream into a method. This is what i
> was doing.
>
> //in the activity
> InputStream filestream = null;
> filestream = mCtx.getResources().openRawResource(R.raw.default_song);
> Document songXml = parseSongAsset(filestream);
> filestream.close();
>
> //the method i used
> public Document parseSongAsset(InputStream filestream ) {
>         try {
>
>                 DocumentBuilder docBuilder = 
> DocumentBuilderFactory.newInstance()
>                                 .newDocumentBuilder();
>                 Document songXml = docBuilder.parse(filestream);
>                 return songXml;
>         } catch (FileNotFoundException e) {
>
> This is what i did to fix it
>
> //in the activity
> Document songXml = parseSongAsset();
>
> //the method
> protected Document parseSongAsset() {
>         try {
>                 InputStream filestream = null;
>                 filestream = mCtx.getResources().openRawResource
> (R.raw.default_song);
>                 DocumentBuilder docBuilder = 
> DocumentBuilderFactory.newInstance()
>                                 .newDocumentBuilder();
>                 Document songXml = docBuilder.parse(filestream);
>                 return songXml;
>         } catch (FileNotFoundException e) {
>
> Anyone got an idea why the the original would break things?
>
> Thanks
> Simon
>
> On Aug 29, 2:40 pm, longhairedsi <longhaire...@googlemail.com> wrote:
>
>
>
> > Hi
>
> > I've just changed my app to load an xml file from a raw resource
> > instead of from the sdcard. Every time i run the app it now fails in a
> > spectacular way. It just closes down, no exceptions. Log output is
> > below.
>
> > I'm not kidding, all i changed was the way an xml file is loaded. If
> > change back and it's fine
>
> > Please help!
>
> > Cheers
> > Simon
>
> > 08-29 14:24:32.979: INFO/DEBUG(1236): *** *** *** *** *** *** *** ***
> > *** *** *** *** *** *** *** ***
> > 08-29 14:24:32.979: INFO/DEBUG(1236): Build fingerprint: 'tmeu/kila_eu/
> > dream/trout:1.5/CRC37/150879:user/ota-rel-keys,release-keys'
> > 08-29 14:24:32.979: INFO/DEBUG(1236): pid: 1710, tid: 1711  >>>
> > com.basementajax.microjam <<<
> > 08-29 14:24:32.979: INFO/DEBUG(1236): signal 11 (SIGSEGV), fault addr
> > 00000004
> > 08-29 14:24:32.979: INFO/DEBUG(1236):  r0 00000004  r1 40021800  r2
> > 00000004  r3 ad32aa45
> > 08-29 14:24:32.979: INFO/DEBUG(1236):  r4 00000000  r5 00000000  r6
> > ad344125  r7 4100afb8
> > 08-29 14:24:32.989: INFO/DEBUG(1236):  r8 100ffcb0  r9 4100afb0  10
> > 41a46450  fp 00001071
> > 08-29 14:24:32.989: INFO/DEBUG(1236):  ip ad36492c  sp 100ffc98  lr
> > ad32aa4f  pc afb045a8  cpsr 00000010
> > 08-29 14:24:33.309: INFO/DEBUG(1236):          #00  pc 000045a8  /
> > system/lib/libcutils.so
> > 08-29 14:24:33.309: INFO/DEBUG(1236):          #01  lr ad32aa4f  /
> > system/lib/libandroid_runtime.so
> > 08-29 14:24:33.319: INFO/DEBUG(1236): stack:
> > 08-29 14:24:33.319: INFO/DEBUG(1236):     100ffc58  00000000
> > 08-29 14:24:33.319: INFO/DEBUG(1236):     100ffc5c  00197e80  [heap]
> > 08-29 14:24:33.319: INFO/DEBUG(1236):     100ffc60  00000000
> > 08-29 14:24:33.319: INFO/DEBUG(1236):     100ffc64  00169140  [heap]
> > 08-29 14:24:33.319: INFO/DEBUG(1236):     100ffc68  100ffcc8
> > 08-29 14:24:33.329: INFO/DEBUG(1236):     100ffc6c  00197e80  [heap]
> > 08-29 14:24:33.329: INFO/DEBUG(1236):     100ffc70  423907a0
> > 08-29 14:24:33.329: INFO/DEBUG(1236):     100ffc74  000000c1
> > 08-29 14:24:33.329: INFO/DEBUG(1236):     100ffc78  40021800
> > 08-29 14:24:33.329: INFO/DEBUG(1236):     100ffc7c  000000c2
> > 08-29 14:24:33.329: INFO/DEBUG(1236):     100ffc80  00000000
> > 08-29 14:24:33.339: INFO/DEBUG(1236):     100ffc84  00000000
> > 08-29 14:24:33.339: INFO/DEBUG(1236):     100ffc88  00000000
> > 08-29 14:24:33.339: INFO/DEBUG(1236):     100ffc8c  00000000
> > 08-29 14:24:33.339: INFO/DEBUG(1236):     100ffc90  df002777
> > 08-29 14:24:33.349: INFO/DEBUG(1236):     100ffc94  e3a070ad
> > 08-29 14:24:33.349: INFO/DEBUG(1236): #00 100ffc98  00000000
> > 08-29 14:24:33.349: INFO/DEBUG(1236):     100ffc9c  ad32aa4f  /system/
> > lib/libandroid_runtime.so
> > 08-29 14:24:33.359: INFO/DEBUG(1236):     100ffca0  100ffcd0
> > 08-29 14:24:33.359: INFO/DEBUG(1236):     100ffca4  ad344135  /system/
> > lib/libandroid_runtime.so
> > 08-29 14:24:33.359: INFO/DEBUG(1236):     100ffca8  410a99d0
> > 08-29 14:24:33.359: INFO/DEBUG(1236):     100ffcac  ad00e3b8  /system/
> > lib/libdvm.so
> > 08-29 14:24:33.359: INFO/DEBUG(1236):     100ffcb0  410a99d0
> > 08-29 14:24:33.359: INFO/DEBUG(1236):     100ffcb4  000f7430  [heap]
> > 08-29 14:24:33.369: INFO/DEBUG(1236):     100ffcb8  ad344125  /system/
> > lib/libandroid_runtime.so
> > 08-29 14:24:33.369: INFO/DEBUG(1236):     100ffcbc  40021800
> > 08-29 14:24:33.369: INFO/DEBUG(1236):     100ffcc0  410a99d0
> > 08-29 14:24:33.369: INFO/DEBUG(1236):     100ffcc4  afe39dd0
> > 08-29 14:24:33.369: INFO/DEBUG(1236):     100ffcc8  100ffcd0
> > 08-29 14:24:33.369: INFO/DEBUG(1236):     100ffccc  ad040a8d  /system/
> > lib/libdvm.so
> > 08-29 14:24:33.379: INFO/DEBUG(1236):     100ffcd0  4100afb0
> > 08-29 14:24:33.379: INFO/DEBUG(1236):     100ffcd4  41c44fd4
> > 08-29 14:24:33.379: INFO/DEBUG(1236):     100ffcd8  ad344125  /system/
> > lib/libandroid_runtime.so
> > 08-29 14:24:33.379: INFO/DEBUG(1236):     100ffcdc  100ffd48
> > 08-29 14:24:34.109: INFO/ActivityManager(62): Process
> > com.basementajax.microjam (pid 1710) has died.
> > 08-29 14:24:34.119: INFO/WindowManager(62): WIN DEATH: Window{433928a8
> > com.basementajax.microjam/com.basementajax.microjam.MicroJam
> > paused=false}
> > 08-29 14:24:34.119: INFO/DEBUG(1236): debuggerd committing suicide to
> > free the zombie!
> > 08-29 14:24:34.129: DEBUG/Zygote(34): Process 1710 terminated by
> > signal (11)
> > 08-29 14:24:34.169: INFO/DEBUG(1723): debuggerd: Aug  6 2009 17:14:09
> > 08-29 14:24:34.179: INFO/WindowManager(62): WIN DEATH: Window{4343fbc8
> > com.basementajax.microjam/com.basementajax.microjam.MicroJam
> > paused=false}
> > 08-29 14:24:34.199: INFO/WindowManager(62): Setting rotation to 0,
> > animFlags=0
> > 08-29 14:24:34.219: INFO/WindowManager(62): Config changed:
> > { scale=1.0 imsi=0/0 locale=en_GB touch=3 key=2/1/2 nav=3 orien=1 }
> > 08-29 14:24:34.229: INFO/WindowManager(62): Config changed:
> > { scale=1.0 imsi=0/0 locale=en_GB touch=3 key=2/1/2 nav=3 orien=1 }
> > 08-29 14:24:34.239: WARN/SurfaceComposerClient(62): Destroying surface
> > while a transaction is open. Client 0x1f8ba8: destroying surface 0,
> > mTransactionOpen=1
> > 08-29 14:24:34.239: WARN/WindowManager(62):
> > performLayoutAndPlaceSurfacesLocked called while in layout- Hide quoted 
> > text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to