diff --git a/src/pxb/android/StringItems.java b/src/pxb/android/StringItems.java index abdb849..16ac35e 100644 --- a/src/pxb/android/StringItems.java +++ b/src/pxb/android/StringItems.java @@ -106,8 +106,8 @@ public void prepare() throws IOException { item.dataOffset = offset; map.put(stringData, offset); if (useUTF8) { - int length = stringData.length(); - byte[] data = stringData.getBytes("UTF-8"); + int length = stringData == null ? 0 : stringData.length(); + byte[] data = stringData == null ? new byte[0] : stringData.getBytes("UTF-8"); int u8lenght = data.length; if (length > 0x7F) { @@ -125,8 +125,8 @@ public void prepare() throws IOException { baos.write(0); offset += 3 + u8lenght; } else { - int length = stringData.length(); - byte[] data = stringData.getBytes("UTF-16LE"); + int length = stringData == null ? 0 :stringData.length(); + byte[] data = stringData == null ? new byte[0] : stringData.getBytes("UTF-16LE"); if (length > 0x7FFF) { int x = (length >> 16) | 0x8000; baos.write(x);