Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference

后端 未结 6 656
忘了有多久
忘了有多久 2021-02-07 01:46

I have BitmapScalingHelper.java:

public class BitmapScalingHelper
{
    public static Bitmap decodeResource(Resources res, int resId, int dstWidth, int dstHeigh         


        
6条回答
  •  闹比i
    闹比i (楼主)
    2021-02-07 02:33

    There are some reasons may cause the error.

    1. Lack of the Permission in AndroidManifest.xml. Read or write permission.
    2. The file doesn't exist or you are trying to access to a file that could't be decoded as a bitmap.

    From the code you post,I can't find any logic error.Here are my suggestions:

    1. Change another image and test.

    2. Try to use ImageLoader Library like Glide or Fresco and test.

提交回复
热议问题