Domanda

java.lang.NullPointerException: println needs a message 
at android.util.Log.println_native(Native Method) 
at android.util.Log.e(Log.java:230) 
at android.sec.clipboard.data.ClipboardDataMgr.addData(ClipboardDataMgr.java:166) 
at com.android.server.sec.InternalClipboardExService.addData(InternalClipboardExService.java:438) 
at com.android.server.sec.InternalClipboardExService.access$300(InternalClipboardExService.java:75) 
at com.android.server.sec.InternalClipboardExService$1.run(InternalClipboardExService.java:389) 
at java.lang.Thread.run(Thread.java:1019)

Seem to be getting this quite often in my crash reporting, i can't for the life of my understand how or why or even where its happening?

The only location im performing anything on the clipboard is to copy data to it, no logging or println of any kind, not to mention i'm choosing the correct methods for the version of OS at runtime so i didnt hit any compat issues.

oh, and the devices range from 2.2 right up to 4.0 OS version

Perhaps relevant code?

int currentapiVersion = android.os.Build.VERSION.SDK_INT;
if (currentapiVersion >= android.os.Build.VERSION_CODES.HONEYCOMB) {
    try {
        android.content.ClipboardManager clipboard = (android.content.ClipboardManager) acc
                .getSystemService(Context.CLIPBOARD_SERVICE);
        ClipData clip = ClipData.newPlainText("", b);
        clipboard.setPrimaryClip(clip);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
} else {
    try {
        android.text.ClipboardManager clipboard = (android.text.ClipboardManager) acc
                .getSystemService(Context.CLIPBOARD_SERVICE);
        clipboard.setText(b);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
È stato utile?

Soluzione 2

Anyway, your error is not there: It is not catched by your try...catch because it is happening on another thread as you can see in your stack trace.

According to the developers of Clipper - Clipboard Manager:

SAMSUNG USERS: Some devices have a randomly occurring bug that may cause the clipboard to crash in any application. This is unfortunately out of our control. If you are experiencing this problem with your device, please contact Samsung support for assistance.

This might be also caused (later on since you said up to 4.0) by version 4.3: Copy crash in Android 4.3 when clipboard listener attached

Also read this guy's post (seems he experienced the issue): http://forum.xda-developers.com/showthread.php?t=2097929


In summary, I do not think this error is your responsibility.

Altri suggerimenti

the error means that the second parameter of Log.* can not be null, otherwise a Nenter code herePE is thrown. That could happen, for instance, when you try to print the message returned by an exception (e.getMessage()).

String message = null;
Log.i("TAG", message);

that`s kind of situation are the cause of that exception. A possible workaround

String message = null;
Log.i("TAG", ((message == null) ? "string null" : message));
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top