Skip to content

Commit

Permalink
Merge pull request #2598 from square/py/build_error
Browse files Browse the repository at this point in the history
Improve error message when android.os.Build class missing
  • Loading branch information
pyricau authored Jan 2, 2024
2 parents 8e4c802 + a8395f4 commit 93d76d1
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ class AndroidBuildMirror(
*/
fun fromHeapGraph(graph: HeapGraph): AndroidBuildMirror {
return graph.context.getOrPut(AndroidBuildMirror::class.java.name) {
val buildClass = graph.findClassByName("android.os.Build")!!
// checkNotNull for more helpful message than NPE if this isn't an Android hprof.
// Not doing checkNotNull for other classes, if android.os.Build is there it's definitely
// an Android heap dump.
val buildClass = checkNotNull(graph.findClassByName("android.os.Build")) {
"android.os.Build class missing from heap dump, is this an Android heap dump?"
}
val versionClass = graph.findClassByName("android.os.Build\$VERSION")!!
val manufacturer = buildClass["MANUFACTURER"]!!.value.readAsJavaString()!!
val sdkInt = versionClass["SDK_INT"]!!.value.asInt!!
Expand Down

0 comments on commit 93d76d1

Please sign in to comment.