“Canvas: trying to draw too large bitmap” when Android N Display Size set larger than Small

后端 未结 12 1325
清酒与你
清酒与你 2020-11-27 14:51

I have a published app that is crashing at startup on Android N when the newly introduced Display size OS setting is set to too large a value.

When I lo

相关标签:
12条回答
  • 2020-11-27 15:26

    In my case, I just changed the canvas of image which is used in the background using Paint3d(or you can use any other). Here I am sharing a screenshot just go through it.

    0 讨论(0)
  • 2020-11-27 15:27

    it is solved by resizing the images to a lower size.

    0 讨论(0)
  • 2020-11-27 15:31

    Try to use Bitmap.Factory class, this link will help you Loading Large Bitmaps Efficiently

    0 讨论(0)
  • 2020-11-27 15:33

    I checked the Logcat

    Process: co.coolresume, PID: 11145 java.lang.RuntimeException: Canvas: trying to draw too large(572166144bytes) bitmap. at android.view.DisplayListCanvas.throwIfCannotDraw(DisplayListCanvas.java:229) at android.view.RecordingCanvas.drawBitmap(RecordingCanvas.java:97) at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:529) at android.widget.ImageView.onDraw(ImageView.java:1367) at android.view.View.draw(View.java:19380)

    I solved the error using the next manifest

     <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        android:hardwareAccelerated="false">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
    
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
    
    0 讨论(0)
  • 2020-11-27 15:37

    I solved the problem after adding the below code into the Manifest file's application tag in between android: lines.

    android:hardwareAccelerated="false"
    
    0 讨论(0)
  • 2020-11-27 15:38

    There are some scenarios where Original Bitmap needs be Drawn into ImageViews, Photo Editing apps etc...,

    as bay mentioned above setting

    android:hardwareAccelerated="false"
    

    will Cause bad UI experince, You can set hardwareAccelerated Only one selected Activity where high res image to be drawn

    <application android:hardwareAccelerated="true">
        <activity ... />
        <activity android:hardwareAccelerated="false" />
    </application>
    
    0 讨论(0)
提交回复
热议问题