{"record":{"id":"9545be66dbe85f30","repo":"microg/GmsCore","slug":"null-reference","errorCode":null,"errorMessage":"null reference","messagePattern":"null reference","errorType":"exception","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"play-services-base/src/main/java/com/google/android/gms/common/data/BitmapTeleporter.java","lineNumber":61,"sourceCode":"        this.fileDescriptor = parcelFileDescriptor;\n        this.status = status;\n        this.targetBitmap = null;\n        this.isParceled = false;\n    }\n\n    public BitmapTeleporter(Bitmap bitmap) {\n        this.versionCode = 1;\n        this.fileDescriptor = null;\n        this.status = 0;\n        this.targetBitmap = bitmap;\n        this.isParceled = true;\n    }\n\n    public final Bitmap createTargetBitmap() {\n        if (!this.isParceled) {\n            ParcelFileDescriptor parcelFileDescriptor = this.fileDescriptor;\n            if (parcelFileDescriptor == null) {\n                throw new NullPointerException(\"null reference\");\n            }\n            DataInputStream dataInputStream = new DataInputStream(new ParcelFileDescriptor.AutoCloseInputStream(parcelFileDescriptor));\n            try {\n                try {\n                    byte[] bArr = new byte[dataInputStream.readInt()];\n                    int readInt = dataInputStream.readInt();\n                    int readInt2 = dataInputStream.readInt();\n                    Bitmap.Config valueOf = Bitmap.Config.valueOf(dataInputStream.readUTF());\n                    dataInputStream.read(bArr);\n                    close(dataInputStream);\n                    ByteBuffer wrap = ByteBuffer.wrap(bArr);\n                    Bitmap createBitmap = Bitmap.createBitmap(readInt, readInt2, valueOf);\n                    createBitmap.copyPixelsFromBuffer(wrap);\n                    this.targetBitmap = createBitmap;\n                    this.isParceled = true;\n                } catch (IOException e) {\n                    throw new IllegalStateException(\"Could not read from parcel file descriptor\", e);\n                }","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/play-services-base/src/main/java/com/google/android/gms/common/data/BitmapTeleporter.java#L43-L79","documentation":"BitmapTeleporter.createTargetBitmap throws this NullPointerException (message 'null reference', per the play-services-par style) when the bitmap has not been parceled but its ParcelFileDescriptor is null, so there is no pixel data source to read. The teleporter expects either an already-parceled bitmap or a valid file descriptor produced during parceling.","triggerScenarios":"Calling createTargetBitmap() on a BitmapTeleporter that was never written to a Parcel (so fileDescriptor was never populated); manually constructing an empty BitmapTeleporter and trying to read the bitmap; calling it twice on a fresh instance after close/stream already consumed state in a way that nulled the descriptor.","commonSituations":"Deserializing an incompletely transferred BitmapTeleporter; misusing the class by creating it directly instead of obtaining it from a Parcelable round-trip; error paths where parceling failed silently and the descriptor stayed null.","solutions":["Ensure the BitmapTeleporter goes through a Parcel/Parcelable round-trip (write then read) before calling createTargetBitmap(), which populates the file descriptor.","Check the bitmapper source: call teleportBitmap()/writeToParcel properly with a valid temp directory via setTargetDirectory before use.","Guard the call: only invoke createTargetBitmap() when the descriptor exists (or when the instance came from a valid parcel read).","Catch NullPointerException and surface a clear 'bitmap was never parceled' error in your code."],"exampleFix":"// before\nBitmap bmp = teleporter.createTargetBitmap(); // NPE if never parceled\n\n// after\nif (teleporter.isParceled() || teleporterHasDescriptor(teleporter)) {\n    Bitmap bmp = teleporter.createTargetBitmap();\n} else {\n    Bitmap bmp = originalBitmap; // use in-memory source instead\n}","handlingStrategy":"type-guard","validationCode":"if (teleporter == null || (!teleporter.isParceled && !hasDescriptor)) {\n    Log.w(TAG, \"BitmapTeleporter has no parceled data\");\n    return null;\n}","typeGuard":"boolean isReadable(BitmapTeleporter t) {\n    return t.isParceled || t.getFileDescriptorSafe() != null; // only via Parcelable round-trip\n}","tryCatchPattern":"try {\n    return teleporter.createTargetBitmap();\n} catch (NullPointerException e) {\n    Log.w(TAG, \"BitmapTeleporter was never parceled\", e);\n    return fallbackBitmap;\n}","preventionTips":["Only consume BitmapTeleporter instances obtained from a completed Parcelable round-trip.","Call setTargetDirectory and parcel the bitmap before reading.","Track a boolean in your transport layer confirming parceling succeeded.","Never construct BitmapTeleporter manually for reading purposes."],"tags":["android","parcel","null-pointer","bitmap"],"backgroundTag":"null-argument","analyzedSha":"157c9d86ac46c195a86c2f15ab55c84036223f95","analyzedAt":"2026-09-06T17:27:33.892Z","contentChangedAt":"2026-09-06T17:27:33.892Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}