0

Doing flutter build apk --release --no-shrink I get the .apk build created successfully and runs fine on physical device aswel.

I'm trying to obfuscate with following command, which is a recommended way on flutter docs, here.

flutter build apk --obfuscate --split-debug-info=/<project-name>/<directory>

Which fails and throws following

FAILURE: Build failed with an exception.

* Where:
Script 'C:\Programs\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 904

* What went wrong:
Execution failed for task ':app:compileFlutterBuildRelease'.
> Process 'command 'C:\Programs\flutter\bin\flutter.bat'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 20s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done                      21.3s
Gradle task assembleRelease failed with exit code 1

Here It was suggested to use flutter build apk --obfuscate --split-debug-info=debug_info which makes the build process successful but after installing app crash on start.

flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 1.22.5, on Microsoft Windows [Version 10.0.17763.1697], locale en-GB)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    X Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[√] Android Studio (version 4.0)
[√] Connected device (1 available)
AlphaTry
  • 475
  • 5
  • 27
  • check this https://stackoverflow.com/questions/54552962/flutter-build-error-process-command-e-flutter-apps-flutter-bin-flutter-bat – everim Jan 18 '21 at 16:40
  • I've checked all my assets and all are mentioned in the pubspec.yaml – AlphaTry Jan 18 '21 at 17:24

1 Answers1

1

In build.gradle

    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.release

            shrinkResources true
            minifyEnabled true
            // useProguard true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
        }
    }

I was using msal_mobile for authentication and added -keep class com.microsoft.identity.** { *; } in my 'proguard-rules.pro' file. I picked this from the error spotted in adb logcat platform_view_android_jni_impl.

adb logcat

01-21 18:29:20.435 17876 17876 E flutter : [ERROR:flutter/shell/platform/android/platform_view_android_jni_impl.cc(43)] java.lang.AssertionError: AssertionError (GSON 2.8.6): java.lang.NoSuchFieldException: DEFAULT
01-21 18:29:20.435 17876 17876 E flutter :      at c.b.b.f.a(Unknown Source:54)
01-21 18:29:20.435 17876 17876 E flutter :      at c.b.b.f.a(Unknown Source:4)
01-21 18:29:20.435 17876 17876 E flutter :      at c.b.b.f.a(Unknown Source:9)
01-21 18:29:20.435 17876 17876 E flutter :      at c.b.b.f.a(Unknown Source:0)
01-21 18:29:20.435 17876 17876 E flutter :      at com.microsoft.identity.client.y.a(Unknown Source:71)
01-21 18:29:20.435 17876 17876 E flutter :      at com.microsoft.identity.client.y.a(Unknown Source:6)
01-21 18:29:20.435 17876 17876 E flutter :      at com.microsoft.identity.client.y.a(Unknown Source:5)
01-21 18:29:20.435 17876 17876 E flutter :      at com.microsoft.identity.client.w.a(Unknown Source:15)
01-21 18:29:20.435 17876 17876 E flutter :      at c.a.a.b.a(Unknown Source:16)
01-21 18:29:20.435 17876 17876 E flutter :      at c.a.a.a.a(Unknown Source:28)
01-21 18:29:20.435 17876 17876 E flutter :      at c.a.a.a.a(Unknown Source:196)
01-21 18:29:20.435 17876 17876 E flutter :      at d.a.c.a.i$a.a(Unknown Source:17)
01-21 18:29:20.435 17876 17876 E flutter :      at io.flutter.embedding.engine.e.b.a(Unknown Source:57)
01-21 18:29:20.435 17876 17876 E flutter :      at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(Unknown Source:4)
01-21 18:29:20.435 17876 17876 E flutter :      at android.os.MessageQueue.nativePollOnce(Native Method)
01-21 18:29:20.435 17876 17876 E flutter :      at android.os.MessageQueue.next(MessageQueue.java:336)
01-21 18:29:20.435 17876 17876 E flutter :      at android.os.Looper.loop(Looper.java:197)
01-21 18:29:20.435 17876 17876 E flutter :      at android.app.ActivityThread.main(ActivityThread.java:8167)
01-21 18:29:20.435 17876 17876 E flutter :      at java.lang.reflect.Method.invoke(Native Method)
01-21 18:29:20.435 17876 17876 E flutter :      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
01-21 18:29:20.435 17876 17876 E flutter :      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
01-21 18:29:20.435 17876 17876 E flutter : Caused by: java.lang.AssertionError: java.lang.NoSuchFieldException: DEFAULT
01-21 18:29:20.435 17876 17876 E flutter :      at c.b.b.z.n.n$k0.<init>(Unknown Source:87)
01-21 18:29:20.435 17876 17876 E flutter :      at c.b.b.z.n.n$w.a(Unknown Source:29)
01-21 18:29:20.435 17876 17876 E flutter :      at c.b.b.f.a(Unknown Source:74)
01-21 18:29:20.435 17876 17876 E flutter :      at c.b.b.z.n.i.a(Unknown Source:42)
01-21 18:29:20.435 17876 17876 E flutter :      at c.b.b.z.n.i.a(Unknown Source:123)
01-21 18:29:20.435 17876 17876 E flutter :      at c.b.b.z.n.i.a(Unknown Source:22)
01-21 18:29:20.435 17876 17876 E flutter :      at c.b.b.f.a(Unknown Source:74)
01-21 18:29:20.435 17876 17876 E flutter :      at c.b.b.f.a(Unknown Source:16)
01-21 18:29:20.435 17876 17876 E flutter :      ... 20 more
01-21 18:29:20.435 17876 17876 E flutter : Caused by: java.lang.NoSuchFieldException: DEFAULT
01-21 18:29:20.435 17876 17876 E flutter :      at java.lang.Class.getField(Class.java:1604)
01-21 18:29:20.435 17876 17876 E flutter :      at c.b.b.z.n.n$k0.<init>(Unknown Source:34)
01-21 18:29:20.435 17876 17876 E flutter :      ... 27 more
01-21 18:29:20.435 17876 17876 E flutter :
01-21 18:29:20.435 17876 17876 F flutter : [FATAL:flutter/shell/platform/android/platform_view_android_jni_impl.cc(942)] Check failed: CheckException(env).
01-21 18:29:20.436 17876 17876 F libc    : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 17876 (mple.StevensPin), pid 17876 (mple.StevensPin)
AlphaTry
  • 475
  • 5
  • 27