You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter生产环境崩溃:FlutterJNI.nativeSurfaceDestroyed与libflutter.so SIGSEGV

Flutter生产环境随机崩溃问题求助

我的Flutter应用在生产环境运行一段时间后会随机崩溃,日志显示问题与FlutterJNI.nativeSurfaceDestroyed以及libflutter.so中的SIGSEGV(段错误)相关。以下是崩溃日志、环境详情及当前配置,恳请技术协助!

🔹 崩溃日志

1. FlutterJNI.nativeSurfaceDestroyed 与 Input dispatching timed out (No focused window)

#03  pc 0x000000000046e7ac  /data/app/~~fKb_7A3RSZsyRZdpityG3w==/com.app.testApp-fYVYtg6ltGYh2XGl35QxzA==/split_config.arm64_v8a.apk!libflutter.so
  #04  pc 0x0000000000482464  /data/app/~~fKb_7A3RSZsyRZdpityG3w==/com.app.testApp-fYVYtg6ltGYh2XGl35QxzA==/split_config.arm64_v8a.apk!libflutter.so
  #05  pc 0x00000000007c814c  /data/app/~~fKb_7A3RSZsyRZdpityG3w==/com.app.testApp-fYVYtg6ltGYh2XGl35QxzA==/split_config.arm64_v8a.apk!libflutter.so
  #06  pc 0x0000000000466be8  /data/app/~~fKb_7A3RSZsyRZdpityG3w==/com.app.testApp-fYVYtg6ltGYh2XGl35QxzA==/split_config.arm64_v8a.apk!libflutter.so
  #07  pc 0x0000000000469300  /data/app/~~fKb_7A3RSZsyRZdpityG3w==/com.app.testApp-fYVYtg6ltGYh2XGl35QxzA==/split_config.arm64_v8a.apk!libflutter.so
  at io.flutter.embedding.engine.FlutterJNI.nativeSurfaceDestroyed (Native method)
  at io.flutter.embedding.engine.FlutterJNI.onSurfaceDestroyed (FlutterJNI.java:667)
  at io.flutter.embedding.engine.renderer.FlutterRenderer.stopRenderingToSurface (FlutterRenderer.java:1125)
  at io.flutter.embedding.android.FlutterSurfaceView.disconnectSurfaceFromRenderer (FlutterSurfaceView.java:303)
  at io.flutter.embedding.android.FlutterSurfaceView.access$400 (FlutterSurfaceView.java:36)
  at io.flutter.embedding.android.FlutterSurfaceView$1.surfaceDestroyed (FlutterSurfaceView.java:78)
  at android.view.SurfaceView.notifySurfaceDestroyed (SurfaceView.java:1943)
  at android.view.SurfaceView.updateSurface (SurfaceView.java:1191)
  at android.view.SurfaceView.onWindowVisibilityChanged (SurfaceView.java:343)
  at android.view.View.dispatchWindowVisibilityChanged (View.java:14927)
  at android.view.ViewGroup.dispatchWindowVisibilityChanged (ViewGroup.java:1625)
  at android.view.ViewGroup.dispatchWindowVisibilityChanged (ViewGroup.java:1625)
  at android.view.ViewGroup.dispatchWindowVisibilityChanged (ViewGroup.java:1625)
  at android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:2844)

2. libflutter.so 中的 SIGSEGV (Segmentation Fault)

pc 0x00000000007bf548  /data/app/~~app.testApprNfba4VBBO2u9sIA==/com.radha.radhe_krishna-rOmGvGDsSf2vWoA-E6LYGg==/split_config.arm64_v8a.apk!libflutter.so (BuildId: 3535a404fab93d565fa72d50842926306c89a4de)
  #11  pc 0x00000000007beee8  /data/app/~~app.testApprNfba4VBBO2u9sIA==/com.radha.radhe_krishna-rOmGvGDsSf2vWoA-E6LYGg==/split_config.arm64_v8a.apk!libflutter.so (BuildId: 3535a404fab93d565fa72d50842926306c89a4de)
  #12  pc 0x00000000007c02a4  /data/app/~~app.testApprNfba4VBBO2u9sIA==/com.radha.radhe_krishna-rOmGvGDsSf2vWoA-E6LYGg==/split_config.arm64_v8a.apk!libflutter.so (BuildId: 3535a404fab93d565fa72d50842926306c89a4de)
  #13  pc 0x00000000007bfdac  /data/app/~~app.testApprNfba4VBBO2u9sIA==/com.radha.radhe_krishna-rOmGvGDsSf2vWoA-E6LYGg==/split_config.arm64_v8a.apk!libflutter.so (BuildId: 3535a404fab93d565fa72d50842926306c89a4de)
  #14  pc 0x00000000007cc35c  /data/app/~~app.testApprNfba4VBBO2u9sIA==/com.radha.radhe_krishna-rOmGvGDsSf2vWoA-E6LYGg==/split_config.arm64_v8a.apk!libflutter.so (BuildId: 3535a404fab93d565fa72d50842926306c89a4de)
  #15  pc 0x00000000004811ac  /data/app/~~app.testApprNfba4VBBO2u9sIA==/com.radha.radhe_krishna-rOmGvGDsSf2vWoA-E6LYGg==/split_config.arm64_v8a.apk!libflutter.so (BuildId: 3535a404fab93d565fa72d50842926306c89a4de)
  #16  pc 0x0000000000484ce0  /data/app/~~app.testApprNfba4VBBO2u9sIA==/com.radha.radhe_krishna-rOmGvGDsSf2vWoA-E6LYGg==/split_config.arm64_v8a.apk!libflutter.so (BuildId: 3535a404fab93d565fa72d50842926306c89a4de)
  #17  pc 0x0000000000018024  /system/lib64/libutils.so (android::Looper::pollInner(int)+1064)
  #18  pc 0x0000000000017b98  /system/lib64/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+116)
  #19  pc 0x0000000000018598  /system/lib64/libandroid.so (ALooper_pollOnce+104)
  #20  pc 0x0000000000484dec  /data/app/~~app.testApprNfba4VBBO2u9sIA==/com.radha.radhe_krishna-rOmGvGDsSf2vWoA-E6LYGg==/split_config.arm64_v8a.apk!libflutter.so (BuildId: 3535a404fab93d565fa72d50842926306c89a4de)
  #21  pc 0x0000000000482ef0  /data/app/~~app.testApprNfba4VBBO2u9sIA==/com.radha.radhe_krishna-rOmGvGDsSf2vWoA-E6LYGg==/split_config.arm64_v8a.apk!libflutter.so (BuildId: 3535a404fab93d565fa72d50842926306c89a4de)
  #22  pc 0x0000000000482d24  /data/app/~~app.testApp

Flutter环境信息

PS D:\flutter projects\app> flutter doctor -v
[√] Flutter (Channel stable, 3.27.0, on Microsoft Windows [Version 10.0.19045.5487], locale en-IN)
    • Flutter version 3.27.0 on channel stable at D:\Flutter
    • Upstream repository https://github.com/flutter/flutter.git            
    • Framework revision 8495dee1fd (9 weeks ago), 2024-12-10 14:23:39 -0800
    • Engine revision 83bacfc525                                             
    • Dart version 3.6.0                                                     
    • DevTools version 2.40.2 

Build.gradle.kts配置

import java.util.Properties
import java.io.FileInputStream

plugins {
    id("com.android.application")
    id("kotlin-android")
    id("dev.flutter.flutter-gradle-plugin")
}

val keystorePropertiesFile = rootProject.file("key.properties")
val keystoreProperties = Properties()
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(FileInputStream(keystorePropertiesFile))
}

android {
    namespace = "com.app.testApp"
    compileSdk = 34

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = "1.8"
    }

    defaultConfig {
        applicationId = "com.app.testApp"
        minSdk = 23
        targetSdk = 34
        versionCode = flutter.versionCode
        versionName = flutter.versionName
        multiDexEnabled = true
        ndk {
            abiFilters.addAll(listOf("armeabi-v7a", "arm64-v8a", "x86_64"))
        }
    }
    configurations.all {
        resolutionStrategy {
            // Force specific versions to avoid conflicts
            force("com.google.android.play:core-common:2.0.3")
            force("com.google.android.play:app-update:2.1.0")
            force("com.google.android.play:asset-delivery:2.1.0")
            force("com.google.android.play:review:2.0.1")
            force("com.google.android.play:review-ktx:2.0.1")
        }
    }

    signingConfigs {
        create("release") {
            keyAlias = keystoreProperties.getProperty("keyAlias")
            keyPassword = keystoreProperties.getProperty("keyPassword")
            storeFile = keystoreProperties.getProperty("storeFile")?.let { file(it) }
            storePassword = keystoreProperties.getProperty("storePassword")
        }
    }

    buildTypes {
        getByName("release") {
            signingConfig = signingConfigs.getByName("release")
//            isMinifyEnabled = true
//            isShrinkResources = true
            ndk {
                abiFilters.addAll(listOf("armeabi-v7a", "arm64-v8a", "x86_64"))
            }
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )
        }
        getByName("debug") {
            isDebuggable = true
        }
    }

    lint {
        checkReleaseBuilds = false
    }
}

dependencies {
    implementation("org.jetbrains.kotlin:kotlin-stdlib:1.8.22")
    implementation("androidx.multidex:multidex:2.0.1")

    // Instead of using core:1.10.3, use the modular dependencies
    implementation("com.google.android.play:core-common:2.0.3")
    implementation("com.google.android.play:app-update:2.1.0") {
        exclude(group = "com.google.android.play", module = "core")
    }
    implementation("com.google.android.play:asset-delivery:2.1.0") {
        exclude(group = "com.google.android.play", module = "core")
    }
    implementation("com.google.android.play:review:2.0.1") {
        exclude(group = "com.google.android.play", module = "core")
    }
    implementation("com.google.android.play:review-ktx:2.0.1") {
        exclude(group = "com.google.android.play", module = "core-ktx")
    }
}


flutter {
    source = "../.."
}

内容的提问来源于stack exchange,提问作者Amarjeet Patidar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 09:24:50