Hi Diane,

I will post a bug report with example code after the developer
challenge monday deadline.

I've found the problem, it seems to be totaly unrelated, but this is
for sure where the problem comes from. I reverted project then added
code line by line.

This is where it went wrong: (this is in onCreate() )

Typeface face=Typeface.createFromAsset(getAssets(), "fonts/
ds_digi.ttf");
//mode.setTypeface(face);

When I comment out "mode.setTypeface(face);" the application fails.
When I put it back in the app works fine(or if I delete the whole
block)

The app does not fail at this point, but later on, in a seemingly
unrelated operation.

I can't believe i've spent 10 hours on this :(.  10 hours I could have
been improving my app.

Anyway, thats life I suppose! At least i can now finish it.

Thanks
Simon

On Aug 29, 5:30 pm, Dianne Hackborn <[email protected]> wrote:
> Could you please file a bug report with full code to reproduce?
>
> Also I know this is not going to be helpful at all, but I would really
> recommend staying away from DocumentBuilder -- it is a lot more overhead
> compared to directly parsing the XML.
>
> In fact, by far the most efficient way to parse an XML resource is to put it
> in res/xml, and retrieve it with Resources.getXml().  This can be literally
> a couple orders of magnitude faster than using a pull parser on a raw XML
> file.
>
> On Sat, Aug 29, 2009 at 7:30 AM, longhairedsi
> <[email protected]>wrote:
>
>
>
>
>
> > 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 <[email protected]> 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 <[email protected]> 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/
>
> ...
>
> read more »- 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to