Android:java.lang.OutOfMemoryError: Failed to allocate a 23970828 byte allocation with 2097152 free bytes and 2MB until OOM

前端 未结 30 2611
暗喜
暗喜 2020-11-21 07:33

I want to show the Bitmap image in ImageView from sd card which is stored already. After run my application is crash and getting Ou

30条回答
  •  孤城傲影
    2020-11-21 08:08

    Last but not the least....
    
    Try Method One:
    
    Simple Add these lines of code in the gradle file
    
    dexOptions {
            incremental true
            javaMaxHeapSize "4g"
         }
    
    Example:
    
    android {
        compileSdkVersion XX
        buildToolsVersion "28.X.X"
    
        defaultConfig {
            applicationId "com.example.xxxxx"
            minSdkVersion 14
            targetSdkVersion 19
        }
    
    dexOptions {
            incremental true
            javaMaxHeapSize "4g"
         }
    }
    
    *******************************************************************
    
    Method Two:
    
    Add these two lines of code in manifest file...
    
    android:hardwareAccelerated="false" 
    android:largeHeap="true"
    
    Example:
    
    
            
                
                    
    
                    
                
            
        
    
    It will Work for sure any of these cases.....
    

提交回复
热议问题