Android 为什么BitmapFactory.decodeResource()返回null?

Android 为什么BitmapFactory.decodeResource()返回null?,android,kotlin,bitmapfactory,Android,Kotlin,Bitmapfactory,我正在制作一个自定义视图,我希望画布能够绘制我放在res\mipmap文件夹中的图像。但是当我检查用BitmapFactory.decodeResource创建的mipmap是否为空时,android studio会这么说,但我真的不知道为什么 我所做的一切是: class RegistrazioniButton :View { val img=BitmapFactory.decodeResource(resources,R.mipmap.microfono_registrazioni

我正在制作一个自定义视图,我希望画布能够绘制我放在res\mipmap文件夹中的图像。但是当我检查用BitmapFactory.decodeResource创建的mipmap是否为空时,android studio会这么说,但我真的不知道为什么

我所做的一切是:

class RegistrazioniButton :View {

    val img=BitmapFactory.decodeResource(resources,R.mipmap.microfono_registrazioni_round)

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

    override fun onDraw(canvas: Canvas) {
        super.onDraw(canvas)

        if(img==null){
            Log.e("Null","è null")}
        else canvas.drawBitmap(img,10f,10f,null)
    }
}

在这一点上,我真的不知道该怎么做

使用过的图像的分辨率是什么?>在这一点上,我真的不知道该怎么做1-搜索这个网站-这个问题已经出现了很多2-Android是开源的-逐步通过源代码,看看是什么路径导致空值response@blackapps它是600x600
来绘制我放在res\mipmap中的图像
您还没有告诉我是哪种图像。