发布模式下应用程序由于内存问题崩溃。

3
我有一个Flutter应用程序,在Android和iOS上不断崩溃。 我没有得到任何堆栈跟踪。应用程序只是在iOS和Android上最小化。 只有过了一段时间后,我才收到崩溃报告。 我不知道问题出在哪里。 我认为这可能是由于某些内存问题导致的。
以下是我的Android build.gradle文件。我正在使用ListView,在ListView中加载图像。
        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'

1
我在一段时间后收到了崩溃报告。你能把那个崩溃报告发给我们吗? - undefined
一段时间后,我也会收到崩溃报告。但是在调试模式下,没有堆栈跟踪应用程序只是最小化并且失去连接。 - undefined
崩溃报告 ==> 检测到异常应用。您的应用程序遇到频繁的崩溃。 - undefined
你所指的“崩溃报告”是指弹出窗口吗? - undefined
先生,您对这个问题有解决方案了吗? - undefined
你是使用隔离还是计算?我认为这就是导致你的应用程序内存耗尽然后崩溃的原因。 - undefined
1个回答

0

我觉得问题在于你正在使用大尺寸的图片加载到嵌套列表视图中,而且我看不到任何数据库,这意味着你是从应用程序本身静态加载它们。这会导致内存溢出异常,因为应用程序占用了太多的内存。请从像Firebase或SQL这样的数据库中加载图片,或者加载分辨率较低的小型PNG图片。希望能对你有所帮助。


我正在从S3获取图像 - undefined
但它不应该占用那么多空间。我有足够的内存。存在一些内存泄漏。 - undefined

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接