How to get a stack in a mobile device?

I get a NullPointerException in Nokia S40.

I want to know what causes this exception.

The device shows:

NullPointerException java / lang / NullPointerException

This error occurs only in the device running in the emulator, the application works fine.

I use microlog to debug my application. But the application works fine if the log is enabled.

Is there a way to get the stack trace when I get this NullPointerException? I do not need all the data, such as line number, which method raises this exception.

UPDATE: I installed the same application in another Nokia S40, and this error did not occur.

  • Nokia 2660 - error
  • Nokia 6131 - no errors

2:. - , NullPointerException.

    import javax.microedition.lcdui.Canvas;
    import javax.microedition.lcdui.Graphics;

    public class OuterClass extends Canvas {

    private Config config;

    public OuterClass() {
        this.config = new Config();
    }

    public void paint(Graphics graphics) {
        HelperClass helper = new HelperClass(this.config);
        helper.doStuff();
    }

    public void dispose() {
        this.config = null;
    }

    public class Config implements IConfig {
        public int getSomething() {
            // ...
        }
    }
}


 public class HelperClass {

        private IConfig config;

        public HelperClass(IConfig) {
            this.config = config;
        }

        public doStuff() {
            config.getSomething(); // Here is thrown NullPointerException
        }
    }

OuterClass.dispose() helper.doStuff(), NPE. , , , helper.doStuff() , , .

+5
4

Throwable Nokia Series40.

JavaME Series40 , , .

, , :

  • , ( ), Stack, . , , .

  • , . ( ), .

  • , .

  • .

  • try{}catch(Throwable){} ( ).

, , . , script, .

+2

, . exception printStackTrace, , .

, , Java SE java , , System.out =. PrintStream OutputStream, , ByteArrayOutputStream, PrintStream, System.out ex.printStackTrace(). J2ME, , , , System.out - ( , ), . >

RecordStore, , RecordStore , .

, , . System.out. , .

. , System.out System.err . , , (, , ), , . -, - , - / RecordStore, Connection .. , ?

0

Microlog .

Microlog

0
source

You can try to catch the exception in some high-level try / catch block, and then email the trace to yourself.

-2
source

All Articles