26 May 2009, 06:49
Generic-user-small

Alex (1 post)

Ok, so by the end of section 3.5 I was supposed to have something like on fig. 3.8, after adding additional to the AndroidManifest.xml, but I’m still getting the crush like it’s on fig. 3.7!
What is the problem?

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="hello">Hello World, Sudoku!</string>
    <string name="app_name">Sukokuist</string>
    <string name = "main_title">Android SudokkkU</string>
    <string name = "continue_label">Continue</string>
    <string name = "new_game_label">New Game!</string>
    <string name = "about_label">About</string>
    <string name = "exit_label">Exit</string>
    <string name = "about_text">
   Microsoft's old search engine, Windows Live Search, has been unable to gain ground against Google, despite innovative schemes like paying businesses and consumers to use its search engine with programs like "Microsoft Service Credits for Web Search", "SearchPerks!", and Live Search cash back.

In November 2007, Microsoft's share of U.S. searches stood at 9.8%, according to ComScore. At the end of April 2009, its share had dropped to 8.2%.

Microsoft's new search engine, whether it's named Kumo or something that sounds less like a vegan sandwich spread, aims to reverse that trend. The company remains coy about whether the Kumo brand will be kept.

"As for rebranding, it's something we're still considering," Live Search general manager Mike Nichols said in a blog post in March. 
    </string>
</resources>



<pre>
package org.example.sudoku;
import android.app.Activity;
import android.os.Bundle;

public class About extends Activity{

    @Override
    protected void onCreate(Bundle savedInstance){
        super.onCreate(savedInstance);
        setContentView(R.layout.about);
    }
}
<code>

<pre>
package org.example.sudoku;

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

import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;

public class Sudoku extends Activity implements OnClickListener {
    /** Called when the activity is first created. */
       @Override
       public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          // Set up click listeners for all the buttons
          View continueButton = this.findViewById(R.id.continue_button);
          continueButton.setOnClickListener(this);
          View newButton = this.findViewById(R.id.new_button);
          newButton.setOnClickListener(this);
          View aboutButton = this.findViewById(R.id.about_button);
          aboutButton.setOnClickListener(this);
          View exitButton = this.findViewById(R.id.exit_button);
          exitButton.setOnClickListener(this);
       }

       public void onClick(View v){
           switch(v.getId()){
           case R.id.about_button:
               Intent i = new Intent(this, About.class);
               startActivity(i);
               break;
           }
       }
}
<code>

<pre>
<?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:icon="@drawable/icon" android:label="@string/app_name">
        <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_text">
        </activity>
    </application>
    <uses-sdk android:minSdkVersion="3" />
</manifest> 
<code>
26 May 2009, 14:02
Burnette_ed_pragsmall

Ed Burnette (1316 posts)

I pasted in all the code and XML from your posting into my own project and didn’t get a crash. Is it possible there was an error that prevented your new version from getting installed on the phone? Check both Eclipse and the DDMS log (adb logcat) for errors, and force an uninstall by doing “adb uninstall org.example.sudoku” before running again.

If that doesn’t help, then I suggest downloading the source code zip file from http://www.pragprog.com/titles/eband/source_code and comparing your version against the Sudokuv1 project.

Let us know how it goes.

31 May 2009, 04:39
Generic-user-small

Bob Weber (1 post)

FWIW,
I’m getting the same error. Curiously, it’s only happening in portrait mode, not landscape. I’m using that as a clue to try and debug. It happens both in the emulator and on the G1. If anyone resolves it please update this thread….
Thanks!

31 May 2009, 19:59
Burnette_ed_pragsmall

Ed Burnette (1316 posts)

I’m looking into it. Please send me a zip file with your project plus a copy of your log and all error messages. Also let me know what version of the SDK, Eclipse, Java, and Android firmware you have. Thanks.

27 Jun 2009, 14:16
Generic-user-small

Peter Kirn (4 posts)

I got stuck on this for a couple of hours, scratching my head—and now I know the problem. ;)

Check your LogCat. You get:
06-27 05:26:17.253: ERROR/AndroidRuntime(952): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.cdm.android/android.provider.Settings}; have you declared this activity in your AndroidManifest.xml?

I think the problem is that Settings is defined as android.provide.Settings – if you create a new class and call it Settings.java and refer to ”.Settings” in androidmanifest.xml, it seems the app may try to look for android.provider.Settings within your existing package path.

I just changed my name to something else ([YourActivityName]Settings) in the class file and the manifest – bingo, no more crash. I think you can also drop the dot.

Ed, any idea why you didn’t have this problem?

This is SDK 1.5 / Eclipse 3.4 / Java 6. Firmware doesn’t matter – you can do it in the emulator.

01 Jul 2009, 22:10
Burnette_ed_pragsmall

Ed Burnette (1316 posts)

According to http://developer.android.com/guide/topics/manif… ,

“android:name The name of the class that implements the activity, a subclass of Activity. The attribute value should be a fully qualified class name (such as, “com.example.project.ExtracurricularActivity”). However, as a shorthand, if the first character of the name is a period (for example, ”.ExtracurricularActivity”), it is appended to the package name specified in the element. “

It’s possible you’ve found a bug, in which case you should report it at http://code.google.com/p/android/issues/list . Meanwhile, try using a fully qualified name like ‘’ to see if that helps and lets you use your old class name.

22 Jul 2009, 22:57
Generic-user-small

Dubed (2 posts)

Hello all,
First, thanks for the book.

It makes a bit of hour that I have the same error and i don’t understand how to do to makes it work. I’ve got the problem on the About activity.

Same as above, it works on landscape but not in the other way.


Doesn’t work too.

logCat

07-22 20:58:49.930: ERROR/AndroidRuntime(1446): Uncaught handler: thread main exiting due to uncaught exception
07-22 20:58:49.944: ERROR/AndroidRuntime(1446): java.lang.RuntimeException: Unable to start activity ComponentInfo{org.example.sudoku/org.example.sudoku.Sudoku}: java.lang.NullPointerException
07-22 20:47:13.330: ERROR/AndroidRuntime(1428):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2268)
07-22 20:47:13.330: ERROR/AndroidRuntime(1428):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2284)
07-22 20:47:13.330: ERROR/AndroidRuntime(1428):     at android.app.ActivityThread.access$1800(ActivityThread.java:112)

What can I do :
I can launch the application in landscape, open and close the about, open the about in landscape, move it into portrait and then return in landscape.
If I put myself in the main activity and turn it into portrait, it crash.

(sorry for my english : I’am french)

EDIT
Well, I have upgrade my SDK 1.5r2 to 1.5r3. I have make the project in 1.5 and not 1.1 and now it works…
Dunno exactly why but it works…

I can go sleeping now ^^

25 Jul 2009, 01:37
Burnette_ed_pragsmall

Ed Burnette (1316 posts)

That’s weird. I’m glad it’s working now for you but I would like to have known why.

18 Sep 2010, 13:25
Generic-user-small

jay kyung (1 post)

I just got the book yesterday and having the same issue (I declared the activity for ‘About’ but still getting the application error). It works on landscape but not the portrait mode. I have Eclipse 3.6 and java 1.6.0_21-b07 with Android SKD 2.2. I have read this discussion but not sure what is the solution or workaround for the issue. when captured the log file (below and there is no errors by the way), it shows exactly same log for both portrait and landscape mode.

logcat:

[2010-09-18 06:10:10 – Sudoku] ------
[2010-09-18 06:10:10 – Sudoku] Android Launch!
[2010-09-18 06:10:10 – Sudoku] adb is running normally.
[2010-09-18 06:10:10 – Sudoku] Performing org.example.sudoku.Sudoku activity launch
[2010-09-18 06:10:10 – Sudoku] Automatic Target Mode: using existing emulator ‘emulator-5556’ running compatible AVD ‘em33’
[2010-09-18 06:10:11 – Sudoku] Application already deployed. No need to reinstall.
[2010-09-18 06:10:11 – Sudoku] Starting activity org.example.sudoku.Sudoku on device emulator-5556
[2010-09-18 06:10:12 – Sudoku] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=org.example.sudoku/.Sudoku }

when I restart the emulator with sudoku app:

09-18 13:18:01.392: ERROR/AndroidRuntime(300): FATAL EXCEPTION: main
09-18 13:18:01.392: ERROR/AndroidRuntime(300): java.lang.RuntimeException: Unable to start activity ComponentInfo{org.example.sudoku/org.example.sudoku.Sudoku}: java.lang.NullPointerException
09-18 13:18:01.392: ERROR/AndroidRuntime(300): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
09-18 13:18:01.392: ERROR/AndroidRuntime(300): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
09-18 13:18:01.392: ERROR/AndroidRuntime(300): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
09-18 13:18:01.392: ERROR/AndroidRuntime(300): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
09-18 13:18:01.392: ERROR/AndroidRuntime(300): at android.os.Handler.dispatchMessage(Handler.java:99)
09-18 13:18:01.392: ERROR/AndroidRuntime(300): at android.os.Looper.loop(Looper.java:123)
09-18 13:18:01.392: ERROR/AndroidRuntime(300): at android.app.ActivityThread.main(ActivityThread.java:4627)
09-18 13:18:01.392: ERROR/AndroidRuntime(300): at java.lang.reflect.Method.invokeNative(Native Method)
09-18 13:18:01.392: ERROR/AndroidRuntime(300): at java.lang.reflect.Method.invoke(Method.java:521)
09-18 13:18:01.392: ERROR/AndroidRuntime(300): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-18 13:18:01.392: ERROR/AndroidRuntime(300): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-18 13:18:01.392: ERROR/AndroidRuntime(300): at dalvik.system.NativeStart.main(Native Method)
09-18 13:18:01.392: ERROR/AndroidRuntime(300): Caused by: java.lang.NullPointerException
09-18 13:18:01.392: ERROR/AndroidRuntime(300): at org.example.sudoku.Sudoku.onCreate(Sudoku.java:18)
09-18 13:18:01.392: ERROR/AndroidRuntime(300): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-18 13:18:01.392: ERROR/AndroidRuntime(300): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
09-18 13:18:01.392: ERROR/AndroidRuntime(300): ... 11 more
09-18 13:18:01.402: WARN/ActivityManager(60): Force finishing activity org.example.sudoku/.Sudoku
09-18 13:18:01.902: WARN/ActivityManager(60): Activity pause timeout for HistoryRecord{43fa8600 org.example.sudoku/.Sudoku}
09-18 13:18:12.099: WARN/ActivityManager(60): Activity destroy timeout for HistoryRecord{43fa8600 org.example.sudoku/.Sudoku}

16 Nov 2010, 13:35
Burnette_ed_pragsmall

Ed Burnette (1316 posts)

[Sorry it took so long to respond. I don’t check the forums for the older editions very often and the forums software doesn’t notify me when new posts are added. The 3rd edition forum is at http://forums.pragprog.com/forums/152 . You can post questions on any edition there, just include the edition number.]

I’ve seen this happen before when people forget to add the android:id tags to both the portrait and landscape versions of their layout file. Check for that and check for the exact spelling and capitalization.

  You must be logged in to comment