Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Crash in Production Flutter app : io.flutter.embedding.engine.FlutterJNI.nativeSurfaceDestroyed, [split_config.arm64_v8a.apk!libflutter.so]

Flutter App Crashing: FlutterJNI.nativeSurfaceDestroyed & SIGSEGV in libflutter.so

I'm facing crashes in my Flutter app, and the logs point to issues with FlutterJNI.nativeSurfaceDestroyed and SIGSEGV in libflutter.so. The app runs fine for some time, but then crashes randomly. Below are the logs, environment details, and my current setup.


🔹 Crash Logs

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. SIGSEGV (Segmentation Fault) in libflutter.so

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 doctor

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 = "../.."
}

Any help would be appreciated! Thanks in advance. 🚀

like image 891
Amarjeet Patidar Avatar asked Dec 16 '25 21:12

Amarjeet Patidar


1 Answers

Please also update the Java version to the latest JVM version so that the release build is generated with the latest package, reducing the chances of a crash in any flutter versions.

like image 131
Divyesh gami Avatar answered Dec 19 '25 11:12

Divyesh gami



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!