13 Dec 2010, 22:56
Generic-user-small

Morgan Kodysz (5 posts)

So far this book has been an excellent start to learning android 2.2+, however once I reached chapter 3.5 implementing an About box. I have code errors that book doesnt mention.

I am new to android and pretty much anything more complicated that HTML5 so I might come off inexperiences. Plus I am only 23.

Ok Start

Created the about.xml file and imputed the code. It registered correctly without error except the ending , this did not go away til I closed eclipse and reopened program. ?? Than it shows error: Error parsing XML: not well-formed (invalid token)

<?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: />”

Moved on to create the src/org/example/sudoku/About.java file

all the code registers except next to the setContentView(R.layout.about); there is a red x that says “R cannot be resolved to a variable. ?? This is with the same code as book no steps missed.

Than I moved on to the src/org/example/sudoku/Sudoku.java

This part of the book goes everywhere. He list code but assumes everyone knows where to add and where to edit it. Once I imputed the code after viewing the source code from the file download. Ever click listener will not register error code “button cannot be resolved or is not a field?

Than after adding the // ... public void onClick(View v) { switch (v.getId()) { case R.id.about_button: Intent i = new Intent(this, About.class); startActivity(i); break; // More buttons go here (if any) ... } }
}

Eclipse still registers “R.layout.main” as not a field

case R.id.about_button: as not a field

both in Sudoku.java and About.java all the other files created in project are showing good code.

the next step in the excersise is to run app, but I can run the file it than shows this is red text at bottom of eclipse in the Android section

[2010-12-13 15:22:19 – com.android.ide.eclipse.adt.internal.project.AndroidManifestHelper] Parser exception for C:\Users\Morgan\workspace\Sudoku\AndroidManifest.xml: The prefix “adndroid” for attribute “adndroid:name” associated with an element type “activity” is not bound.

Than I imputed the declaration for the activity in the AndroidManifest.xml as such

<?xml version=”1.0” encoding=”utf-8”?>
<manifest xmlns:android=”http://schemas.android.com/apk/res/android” package=”org.example.sudoku” android:versionCode=”1” android:versionName=”1.0”> <activity android:name=”.Sudoku” android:label=”@string/app_name”> <activity adndroid:name=”.About” android:label=”@string/about_title”>

The book says to add the tag after the closing tag of the first one and I am assuming this is correct sense there is only one closing tag in the .xml file

I didnt miss a step and started from 0 code so looking at his files doesnt help me learn.

Also I am using the newest eclipse and latest android api/apk downloads.

Please help

Thanks
Morgan

13 Dec 2010, 23:08
Generic-user-small

Morgan Kodysz (5 posts)

Fixed that typo error. But the other errors still remain.

“[2010-12-13 15:22:19 – com.android.ide.eclipse.adt.internal.project.AndroidManifestHelper] Parser exception for C:\Users\Morgan\workspace\Sudoku\AndroidManifest.xml: The prefix “adndroid” for attribute “adndroid:name” associated with an element type “activity” is not bound.”

Thanks,

Morgan

http://i23.photobucket.com/albums/b389/mkodysz/... Direct link to screen shot of errors

14 Dec 2010, 01:29
Burnette_ed_pragsmall

Ed Burnette (1316 posts)

You have to be vary careful of spelling (e.g., adndroid should be android) and capitalization (scrollview should be ScrollView, minsdkversion should be minSdkVersion). Also you have to be careful to use real ASCII quote characters instead of the funny smart quote characters some word processors like to use (” should be "). I made a few fixes in the AndroidManifest.xml file you posted and got this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
   package="org.example.sudoku" android:versionCode="1" 
   android:versionName="1.0">
   <application android:label="@string/app_name" 
      android:icon="@drawable/icon">
      <activity android:name=".Sudoku" android:label="@string/app_name">
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
      <activity android:name=".About" android:label="@string/about_title">
      </activity>
   </application>
   <uses-sdk android:minSdkVersion="8" />
</manifest>

Other tips:
  • I find the Format command (usually Ctrl+Shift+F) to be helpful in tracking down syntax errors in both XML and Java code. If I run a Format and something doesn’t get indented or colored like I think it should, it usually means I messed up an opening or closing tag (<foo></foo> in XML or {code;} in Java) or misspelled something.
  • Also look for the squiggly underlines in the editor and hover your mouse over that text for more clues.
  • Finally, every once in a while errors can get the editor in a confused state and you have to fix a few, close that editor, and reopen it to see the true remaining errors.
14 Dec 2010, 03:01
Generic-user-small

Morgan Kodysz (5 posts)

Thank you

Ed

Never saw those simple errors. Glad your there to help. Now i feel really crazy. I will follow the code you gave and try it.

Morgan

14 Dec 2010, 23:42
Generic-user-small

Morgan Kodysz (5 posts)

After reviewing code ecplise still says the buttons are not feilds. Also says missing some file
Error generating final archive: java.io.FileNotFoundException: C:\Users\Morgan\workspace\Sudoku\bin\resources.ap_ does not exist – Sudoku – Unknown – Android – Packaging Problem

So I deleted both the hello project and the sudoku project and went to the api and sdk download and selected every package they have.

Hopefully that works

Morgan

16 Dec 2010, 03:33
Burnette_ed_pragsmall

Ed Burnette (1316 posts)

Hard to say without seeing the project, but sometimes you can get packaging problems if you have files in weird places. For example I saw somebody that had a “res” directory under their “layout” directory instead of the other way around. If you’re still stuck feel free to zip up your project and mail it to me (gmail.com account is ed.burnette) so I can point out what’s wrong and offer some diagnostic tips for next time.

17 Dec 2010, 05:41
Generic-user-small

Morgan Kodysz (5 posts)

Ok will do.

When I have a free day I will create a new project and once I get to that section, if it has the same problems I will send you the project file.

25 Dec 2010, 18:03
Burnette_ed_pragsmall

Ed Burnette (1316 posts)

Ok.

  You must be logged in to comment