0
votes

i get this error on some devices but on others everything works.

Caused by java.lang.ClassNotFoundException Didn't find class "android.widget.Magnifier$Builder" on path: DexPathList[[zip file "/data/app/android.myproject-y_q4TlFhfWP/base.apk"], nativeLibraryDirectories=[/data/app/android.myproject-y_q4TlFhfWP/lib/arm64, /data/app/android.myproject-y_q4TlFhfWPN/base.apk!/lib/arm64-v8a, /system/lib64, /system/vendor/lib64]]

I use custom view, crashes on initialization Magnifier

 class CustomView : FrameLayout {
 private var magnifier: Magnifier? = null

constructor(context: Context) : super(context) {
    init(context)
}

constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) {
    init(context)
}

constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
    context,
    attrs,
    defStyleAttr
) {
    init(context)
}

private fun init(context: Context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
        var magnifier = Magnifier.Builder(this)
            .setInitialZoom(2f)
            .build()
    }
}
1

1 Answers

0
votes

Possibly some of your test device's api version below Q(Api 29)

According to the document; https://developer.android.com/reference/android/widget/Magnifier.Builder magnifier builder added in api version 29(Q). So, either change your code to

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {

or remove equality

if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {

and make sure your test devices api version at least 29(Q).