30 Mar 2011, 09:46
Generic-user-small

Peter Koukoulis (4 posts)

Hi

I’m attempting to run the modified about as per the layout suggested in section 3.4. I keep getting the message;
“Sorry!
The application Suduko
(process org.example.suduko)
has stopped unexpectedly.
Please try again.

I have looked in the LogCat and found the following error listed:
“Caused by: java.lang.RuntimeException: Binary XML file line #2: You must supply a layout_width attribute.”

I have however supplied all the layout_width attributes as per the layout suggested in section 3.4. The following is a copy of the main.xml file;


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:background="@color/background" 
    android:layout_height="fill_parent" 
    android:layout_width="fill_parent" 
    android:padding="15dip" 
    android:orientation="horizontal">
    <LinearLayout
        android:orientation="vertical" 
        android:layout_height="wrap_content" 
        android:layout_width="fill_parent"        
        android:layout_gravity="center" 
        android:paddingLeft="20dip" 
        android:paddingRight="20dip">
        <TextView
            android:text="@string/main_title" 
            android:layout_height="wrap_content" 
            android:layout_width="wrap_content" 
            android:layout_gravity="center" 
            android:layout_marginBottom="20dip" 
            android:textSize="24.5sp"/>
        <TableLayout
            android:layout_height="wrap_content" 
            android:layout_width="wrap_content" 
            android:layout_gravity="center" 
            android:stretchColumns="*">
            <TableRow>
                <Button
                    android:id="@+id/continue_button" 
                    android:text="@string/continue_label"/>
                <Button
                    android:id="@+id/new_button" 
                    android:text="@string/new_game_label"/>
            </TableRow>
            <TableRow>
                <Button
                    android:id="@+id/about_button" 
                    android:text="@string/about_label"/>
                <Button
                    android:id="@+id/exit_button" 
                    android:text="@string/exit_label"/>
            </TableRow>            
        </TableLayout>
    </LinearLayout>
</LinearLayout>

Any help would much appreciated.

Thanks

Peter

30 Mar 2011, 10:47
Generic-user-small

Anthony Shaw (115 posts)

Is the error happening when you change the orientation of the device or when you start it up? The main.xml that you posted seems to be the one from res\layout-land and is the one that would be used when you change the orientation of the device to landscape and it does seem to contain a layout_width attribute.

If the error happens when you first start the application with the device in portrait orientation then it would indicate the problem is in the res\layout\main.xml and it is the very first LinearLayout (as indicated by Binary XML file line #2:) that is missing the layout_width attribute.

30 Mar 2011, 11:09
Generic-user-small

Peter Koukoulis (4 posts)

Hi Anthony,

bq.Is the error happening when you change the orientation of the device or when you start it up?bq.
The error occured when I clicked on the About button.

Something I’ve just realised after my first post,
I forgot to update the about.xml file, which I have now done with the following code from page 46;


<?xml version="1.0" encoding="utf-8"?>
<ScrollView
  xmlns:android="http://schemas.android.com/apk/res/android" 
  android:layout_width="fill_parent" 
  android:layout_height="fill_parent" 
  android:padding="10dip">
  <TextView
    android:id="@+id/about_content" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/about_text" />
</ScrollView>

I now get a build error:
Error parsing XML: unbound prefix
Error in an XML file: aborting build

thanks for the help

Peter

30 Mar 2011, 13:16
Generic-user-small

Anthony Shaw (115 posts)

I copied the code you posted into my Sudoku project and it built with no problem. Maybe a ‘Project Clean…’ would do the trick, it’s worth a try. The other thing is are you sure the build error is coming from the about.xml?

30 Mar 2011, 13:34
Generic-user-small

Peter Koukoulis (4 posts)

Hi Anthony,

I tried Prokect -> Clean, but the problem persists.

When I remove the attribute settings for TextView, as follows:


<?xml version="1.0" encoding="utf-8"?>
<ScrollView
  xmlns:android="http://schemas.android.com/apk/res/android" 
  android:layout_width="fill_parent" 
  android:layout_height="fill_parent" 
  android:padding="10dip">
  <TextView
  />
</ScrollView>

then the build completes sucessfully, but as soon as I add all the android attributes, I get the build error:

Error parsing XML: unbound prefix
Error in an XML file: aborting build

Probably a trivial problem, but I’m new to Android. Been a PL/SQL programmer all my life and working with Eclipse is a compete new world to the trusted command line SQL+.

Thanks again for your help!

P;

30 Mar 2011, 14:36
Generic-user-small

Peter Koukoulis (4 posts)

I’ve fixed the build error problem.
I found exactly the same problem described in this:
http://code.google.com/p/android/issues/detail?...

Once I had deleted the error in the Problem view, the build completed sucessfully.

The problem error I get when clicking on the About button:
“Sorry!
The application Suduko
(process org.example.suduko)
has stopped unexpectedly.
Please try again.

I have looked in the LogCat and found the following error listed:
“Caused by: java.lang.RuntimeException: Binary XML file line #2: You must supply a layout_width attribute.”

however still appears :-(

P;

30 Mar 2011, 15:08
Generic-user-small

Anthony Shaw (115 posts)

I will put the trick of just deleting the errors in my little book of Things To Remember.

Since we are back to square one, how about checking about.java to see if it is picking up the right content view. It should be


package org.example.sudoku;

import android.app.Activity;
import android.os.Bundle;

public class About
extends Activity
{
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.about);
    }
}

Note the setContentView should be looking for R.layout.about

BTW: In ‘real life’ I’m a C, C#, Java, Oracle, PL/SQL (and a few other things) programmer. The PL/SQL thing is quite new to me and I use it mainly in APEX and Oracle functions/procedures and it’s a totally different world so I know where your coming from :-)

30 Mar 2011, 21:03
Burnette_ed_pragsmall

Ed Burnette (1316 posts)

Scroll back a few lines in the LogCat and look at the Exception line. It probably says:

java.lang.RuntimeException: Unable to start activity ComponentInfo{org.example.sudoku/org.example.sudoku.About}: java.lang.RuntimeException: Binary XML file line #2: ...

If it doesn’t say .About then the problem is not in your about.xml file.

Check to make sure you only have one copy of about.xml.

If that doesn’t help, check for a “smart quote”, i.e, a quote that looks like a quote but isn’t really (thank you Unicode).

If it’s still not obvious then put the whole project in a zip file and mail it to my gmail.com address (ed.burnette) and I will be happy to load it up in Eclipse and take a look.

  You must be logged in to comment