我在我的应用程序上运行了一个快照,该快照可以在带有API27的Samsung S8和Pixel Emulator上完美运行。但是,当在Nexus 5x模拟器API29上运行它时,在粗体突出显示的行上出现了空点异常(我听说它很容易在代码内轻松看到出现错误的地方)。
val deal_num = document.getLong(“ deal_num”)!!
docref.collection("winning_bid").whereEqualTo("previous_seller_id",userid).addSnapshotListener{value, task->
if(value !=null){
for (document in value!!){
val losing_seller = document.getString("previous_seller_id")
val deal_num = document.getLong("deal_num")!!
if(userid == losing_seller) {
LosingBidNotificationChannel()
val CHANNEL_ID = "Losing Bid"
val intent = Intent(this, Mydeals_seller::class.java).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
}
val pendingIntent = PendingIntent.getActivity(this, 0, intent, 0)
val builder = NotificationCompat.Builder(this, CHANNEL_ID)
.setSmallIcon(R.drawable.openbidicon)
.setContentTitle("OpenBid")
.setContentText("Your bid has lost the lead")
.setStyle(
NotificationCompat.BigTextStyle()
.bigText("Your bid is no longer leading for Deal #${deal_num}")
)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setContentIntent(pendingIntent)
.setChannelId(CHANNEL_ID)
.setAutoCancel(true)
.build()
with(NotificationManagerCompat.from(this)) {
notify(id, builder)
id++
}
}
}
}
}
是否有任何理由为什么会在API 29上返回NullPointerException但在其他设备上运行正常?
我发现了错误。我删除了模拟器并重新安装了它,现在一切似乎都可以正常工作。