如果我尝试在 API 16上打开我的应用(在API 27上它正在运行),我会收到以下异常日志:
V/FA: onActivityCreated
I/dalvikvm: Could not find method android.app.AlarmManager.setExactAndAllowWhileIdle, referenced from method com.text.app.utilities.COLNotification.addPreAlarm
VFY: unable to resolve virtual method 130: Landroid/app/AlarmManager;.setExactAndAllowWhileIdle (IJLandroid/app/PendingIntent;)V
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0021
I/dalvikvm: Could not find method android.app.AlarmManager.setExact, referenced from method com.text.app.utilities.COLNotification.addPreAlarm
W/dalvikvm: VFY: unable to resolve virtual method 129: Landroid/app/AlarmManager;.setExact (IJLandroid/app/PendingIntent;)V
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0084
W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/app/NotificationChannel;)
I/dalvikvm: Could not find method android.app.NotificationChannel.getSound, referenced from method com.text.app.utilities.COLNotification.buildNotification
W/dalvikvm: VFY: unable to resolve virtual method 264: Landroid/app/NotificationChannel;.getSound ()Landroid/net/Uri;
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0131
W/dalvikvm: VFY: unable to resolve exception class 435 (Landroid/os/FileUriExposedException;)
W/dalvikvm: VFY: unable to find exception handler at addr 0x25e
W/dalvikvm: VFY: rejected Lcom/text/app/utilities/COLNotification;.buildNotification (Lcom/text/app/models/appModel;)V
W/dalvikvm: VFY: rejecting opcode 0x0d at 0x025e
W/dalvikvm: VFY: rejected Lcom/text/app/utilities/COLNotification;.buildNotification (Lcom/text/app/models/appModel;)V
W/dalvikvm: Verifier rejected class Lcom/text/app/utilities/COLNotification;
所有警告都是正确的,因为API中不存在“ NotificationChannel ”等方法。
我使用的代码例如“NotificationChannel”没有执行,因为我检查了Build.VERSION.SDK.INT!
究竟是什么问题?有人可以帮忙吗?
答案 0 :(得分:0)
我使用" FileUriException "在一个catch语句中,这导致了问题。
代替:
catch(FileUriException e) {
}
我现在这样做:
catch(Exception e) {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && e instanceof FileUriExposedException) {
}
}