【问题标题】:App crashing due to memory issue in release mode释放模式下由于内存问题导致应用程序崩溃
【发布时间】:2019-07-26 05:50:39
【问题描述】:

我有一个在 Android 和 iOS 上不断崩溃的 Flutter 应用。
我没有得到任何堆栈跟踪。该应用程序只是在 iOS 和 Android 上最小化。
我只是在一段时间后才收到崩溃报告。
我不明白问题是什么。
我认为这是因为一些内存问题。

以下是我的 Android build.gradle 文件。我正在使用 ListViewListView 中加载图像。

        def localProperties = new Properties()
        def localPropertiesFile = rootProject.file('local.properties')
        if (localPropertiesFile.exists()) {
            localPropertiesFile.withReader('UTF-8') { reader ->
                localProperties.load(reader)
            }
        }
        def flutterRoot = localProperties.getProperty('flutter.sdk')
        if (flutterRoot == null) {                      
            throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
        }
        configurations.all {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
                resolutionStrategy.eachDependency { DependencyResolveDetails details ->
                    def requested = details.requested
                    if (requested.group == "com.android.support") {
                        if (!requested.name.startsWith("multidex")) {
                            details.useVersion "26.+"
                        }
                    }
                }
                all*.exclude group: 'com.google.guava', module: 'listenablefuture'
            }
        def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
        if (flutterVersionCode == null) {
            flutterVersionCode = '1'
        }
        def flutterVersionName = localProperties.getProperty('flutter.versionName')
        if (flutterVersionName == null) {
            flutterVersionName = '1.0'
        }
        apply plugin: 'com.android.application'
        apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
        android {
            compileSdkVersion 28
            compileOptions {
                sourceCompatibility 1.8
                targetCompatibility 1.8
            }
            lintOptions {
                disable 'InvalidPackage'
            }
            defaultConfig {
                // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
                applicationId "com.xxx.xxx"
                 minSdkVersion 24

                targetSdkVersion 28
                multiDexEnabled true
                versionCode flutterVersionCode.toInteger()
                versionName flutterVersionName
                 ndk {
                    abiFilters = []
                    abiFilters.addAll(ABI_FILTERS.split(';').collect{it as String})
                }
                testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
            }
            buildTypes {
                release {
                    // TODO: Add your own signing config for the release build.
                    // Signing with the debug keys for now, so `flutter run --release` works.
                    signingConfig signingConfigs.debug
                }
            }
        }
        flutter {
            source '../..'
        }
        dependencies {
            testImplementation 'junit:junit:4.12'
            def supportLibVersion = rootProject.ext.supportLibVersion
            androidTestImplementation 'androidx.test:runner:1.1.1'                   
            androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'   
            implementation "androidx.appcompat:appcompat:$supportLibVersion"
        }
        apply plugin: 'com.google.gms.google-services'

【问题讨论】:

  • 一段时间后我收到了崩溃报告”你能把那个崩溃报告发给我们吗?
  • 一段时间后我也收到了崩溃报告。但是没有堆栈跟踪应用程序只是最大限度地减少在调试模式下失去连接​​。
  • 崩溃报告 ==>检测到异常应用。您的应用经常遇到崩溃。
  • 崩溃报告是指弹出窗口吗?
  • 您好先生,您有解决这个问题的方法吗?

标签: android flutter dart memory-leaks


【解决方案1】:

我认为问题在于您使用大尺寸的图像加载到嵌套列表视图中,我看不到任何数据库,这意味着您正在从应用程序本身静态加载它们。这会导致内存不足异常,因为该应用程序占用了太多内存。请从诸如 firebase 或 sql 之类的数据库中加载它,或者加载具有低分辨率的小 png 大小的图像。希望对您有所帮助。

【讨论】:

  • 我正在从 s3 获取图像
  • 但它不会占用那么多。我有足够的内存。有一些内存泄漏。
猜你喜欢
  • 2012-06-19
  • 2013-05-24
  • 2011-04-29
  • 1970-01-01
  • 1970-01-01
  • 2017-06-09
  • 2013-06-15
  • 1970-01-01
  • 2011-12-31
相关资源
最近更新 更多