【问题标题】:Verifier rejected class on API 16验证程序拒绝 API 16 上的类
【发布时间】:2018-03-08 20:24:51
【问题描述】:

如果我尝试在 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 16 中不存在“NotificationChannel”等方法。
并且我使用的代码(例如“NotificationChannel”)没有执行,因为我检查了 Build.VERSION.SDK.INT!

究竟是什么问题?有人可以帮忙吗?

【问题讨论】:

    标签: android verifyerror


    【解决方案1】:

    我在 catch 语句中使用了“FileUriException”,这导致了问题。

    代替:

    catch(FileUriException e) {
    }
    

    我现在这样做:

    catch(Exception e) {
        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && e instanceof FileUriExposedException) {
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2017-06-11
      • 1970-01-01
      • 2022-08-03
      • 2013-01-21
      • 2015-03-17
      • 1970-01-01
      • 2018-03-06
      • 2016-05-22
      • 2019-03-06
      相关资源
      最近更新 更多