10

I have developed app with Flutter and when i released app on Google Play Store I am getting these crashes but couldn’t find any working solution. Please help me with this. Any help will be appreciated. enter image description here

enter image description here

2 Answers2

1

Your problem seems to be with android and obfuscation making libflutter.so unreachable.

Go ahead and create at ./android/app a file named

proguard-rules.pro

(to be clear, it will be placed at /android/app/proguard-rules.pro)

and add the following rules to it

#Flutter Wrapper
-keepattributes AutoValue
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.**  { *; }
-keep class io.flutter.util.**  { *; }
-keep class io.flutter.view.**  { *; }
-keep class io.flutter.**  { *; }
-keep class io.flutter.plugins.**  { *; }
-keep class com.google.firebase.** { *; }

EDIT: Also add this to android/app/build.gradle, at buildTypes > release:

buildTypes {
       release {
           //…
            proguardFiles getDefaultProguardFile(
                    'proguard-android-optimize.txt'),
                    'proguard-rules.pro'
       }
 }

I also used at the same time, the same solution as @Dharam did:

abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86_64'

save it and flutter clean your project and compile it again.

What this does is tell the obfuscation service (proguard or R8) to keep these files out of obfuscation (it is ok since there's no point on securing files that are already open-source) I have inserted the firebase stuff too since you're using firebase packages and it caused some issues for me as well.

Fernando Rocha
  • 2,416
  • 3
  • 15
  • 28
  • I tried this solution but it didn't work. – Sos. Aug 26 '23 at 00:28
  • @Sos. i just edited my answer with build.gradle instructions too, did you add that to your file when using proguard rules? – Fernando Rocha Aug 26 '23 at 05:00
  • 1
    Yes, I have `proguardFiles 'proguard-rules.pro'` in `app/build.gradle` and even with `ndk.abiFilters`, it didn't work. I voted your solution because obfuscation may cause errors and no point on securing files that are already open-source, like you said. And I hope Flutter fix this very old error. – Sos. Aug 27 '23 at 07:04
1

I resolved this problem by preventing the creation of x86 builds because Flutter doesn't have support for those builds.

To accomplish this, include the following abiFilters in your android/app/build.gradle:

defaultConfig {
    applicationId "com.example.myapp"
    minSdkVersion 21
    targetSdkVersion flutter.targetSdkVersion
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    multiDexEnabled true
    ndk {
        abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64'
    }
}

buildTypes {
    release {
        signingConfig signingConfigs.release
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        ndk {
            abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64'
        }
    }
}
Dharam Budh
  • 515
  • 2
  • 9