Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flutter Release APK crashes with GSON error java.lang.AssertionError: AssertionError (GSON 2.8.5): java.lang.NoSuchFieldException: UNKNOWN E/flutter (14343): #1456

Closed
fritz-playmaker opened this issue Jan 18, 2019 · 13 comments

Comments

@fritz-playmaker
Copy link

Flutter release-apk crashes as soon as I open the app with a GSON error

Error Log

[ERROR:flutter/shell/platform/android/platform_view_android_jni.cc(40)] java.lang.AssertionError: AssertionError (GSON 2.8.5): java.lang.NoSuchFieldException: UNKNOWN
E/flutter (14343): at com.google.a.f.a(Unknown Source)
E/flutter (14343): at com.google.a.f.a(Unknown Source)
E/flutter (14343): at com.google.a.f.a(Unknown Source)
E/flutter (14343): at com.b.a.b.a$a.b(Unknown Source)
E/flutter (14343): at com.b.a.a.onMethodCall(Unknown Source)
E/flutter (14343): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(Unknown Source)
E/flutter (14343): at io.flutter.view.FlutterNativeView.handlePlatformMessage(Unknown Source)
E/flutter (14343): at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter (14343): at android.os.MessageQueue.next(MessageQueue.java:143)
E/flutter (14343): at android.os.Looper.loop(Looper.java:130)
E/flutter (14343): at android.app.ActivityThread.main(ActivityThread.java:6117)
E/flutter (14343): at java.lang.reflect.Method.invoke(Native Method)
E/flutter (14343): at java.lang.reflect.Method.invoke(Method.java:372)
E/flutter (14343): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
E/flutter (14343): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
E/flutter (14343): Caused by: java.lang.AssertionError: java.lang.NoSuchFieldException: UNKNOWN
E/flutter (14343): at com.google.a.b.a.n$a.(Unknown Source)
E/flutter (14343): at com.google.a.b.a.n$24.a(Unknown Source)
E/flutter (14343): at com.google.a.f.a(Unknown Source)
E/flutter (14343): at com.google.a.b.a.a$1.a(Unknown Source)
E/flutter (14343): at com.google.a.f.a(Unknown Source)
E/flutter (14343): ... 15 more
E/flutter (14343): Caused by: java.lang.NoSuchFieldException: UNKNOWN
E/flutter (14343): at java.lang.Class.getField(Class.java:1104)
E/flutter (14343): ... 20 more
E/flutter (14343):
F/flutter (14343): [FATAL:flutter/shell/platform/android/platform_view_android_jni.cc(77)] Check failed: CheckException(env).

@JakeWharton
Copy link
Contributor

It's not clear why this is a Gson problem. It looks like obfuscation removed a field. Can you provide a self-contained sample that fails and demonstrates that Gson has a bug?

@fritz-playmaker
Copy link
Author

@JakeWharton I honestly do not know the steps to reproduce this error. It popped up whilst installing my release apk in Flutter and it explicitly states java.lang.AssertionError: AssertionError (GSON 2.8.5): so i decided to report it here

@oliverbytes
Copy link

oliverbytes commented Feb 9, 2019

I figured the culprit here. It happens when minifyEnabled is set to true. So just disable it and it should fix

I commented these on my app/build.gradle and now works

buildTypes {
        release {
                .........
                minifyEnabled false // set this to false to prevent java.lang.NoSuchFieldException

@burkard
Copy link

burkard commented Apr 2, 2019

You saved me a lot of headaches, @nemoryoliver !
Thanks!!

@oliverbytes
Copy link

I can feel you @burkard . So happy I've helped. You're welcome

@mohsenoid
Copy link

FYI, you are disabling your proguard!! be careful!

@MegatronKing
Copy link

MegatronKing commented Sep 7, 2019

Add the below in proguard-rules.pro, it will be fixed!

-keepclassmembers enum * {*;}

@eug48
Copy link

eug48 commented Nov 18, 2019

I seem to have solved this with flutter build apk --no-shrink ...
My build wasn't using proguard/minifyEnabled, and strangely my APK was crashing on an Android 7 device, but not on an Android 9 device..

@Dorbmon
Copy link

Dorbmon commented Mar 16, 2020

Thanks for your help!You exactly saved me.

@cahyowhy
Copy link

do we have another alternative to use shrink

@Marcono1234
Copy link
Collaborator

Probably same issue as #924

@viroth-ty
Copy link

Add these lines of code, fixed for me

buildTypes {
    release {
        minifyEnabled false
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
} 

@rajatsangrame
Copy link

Add the below in proguard-rules.pro, it will be fixed!

-keepclassmembers enum * {*;}

It worked!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests