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

AssertionError #13

Closed
dmitrikudrenko opened this issue Apr 5, 2016 · 18 comments
Closed

AssertionError #13

dmitrikudrenko opened this issue Apr 5, 2016 · 18 comments
Labels

Comments

@dmitrikudrenko
Copy link

I use last version of smooch libraries (2.1.8). After Smooch.init I get that error

Fatal Exception: java.lang.AssertionError
       at com.google.gson.internal.bind.TypeAdapters$EnumTypeAdapter.(Unknown Source)
       at com.google.gson.internal.bind.TypeAdapters$26.create(Unknown Source)
       at com.google.gson.Gson.doubleAdapter(Unknown Source)
       at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.excludeField(Unknown Source)
       at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.excludeField(Unknown Source)
       at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.(Unknown Source)
       at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.excludeField(Unknown Source)
       at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.excludeField(Unknown Source)
       at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.excludeField(Unknown Source)
       at com.google.gson.Gson.doubleAdapter(Unknown Source)
       at com.google.gson.internal.bind.CollectionTypeAdapterFactory.create(Unknown Source)
       at com.google.gson.Gson.doubleAdapter(Unknown Source)
       at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.excludeField(Unknown Source)
       at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.excludeField(Unknown Source)
       at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.(Unknown Source)
       at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.excludeField(Unknown Source)
       at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.excludeField(Unknown Source)
       at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.excludeField(Unknown Source)
       at com.google.gson.Gson.doubleAdapter(Unknown Source)
       at com.google.gson.Gson.doubleAdapter(Unknown Source)
       at com.google.gson.Gson.doubleAdapter(Unknown Source)
       at com.google.gson.Gson.floatAdapter(Unknown Source)
       at com.google.gson.Gson.floatAdapter(Unknown Source)
       at io.smooch.core.facade.impl.h.a(Unknown Source)
       at io.smooch.core.facade.c.a(Unknown Source)
       at io.smooch.core.service.SmoochService.k(Unknown Source)
       at io.smooch.core.i.run(Unknown Source)
       at io.smooch.core.e.a(Unknown Source)
       at io.smooch.core.e.i(Unknown Source)
       at io.smooch.core.User.getCurrentUser(Unknown Source)
       at io.smooch.core.User.getCurrentUser(Unknown Source)
       at io.smooch.core.p.run(Unknown Source)
       at android.os.Handler.handleCallback(Handler.java:739)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:148)
       at android.app.ActivityThread.main(ActivityThread.java:5417)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
@jugarrit
Copy link
Contributor

Can you please add some steps to reproduce the problem then re-open this issue?

Thanks :)

@nizamsp
Copy link

nizamsp commented May 24, 2016

In my production version, 89 crashes happened with the same error.
All these crashes on background (app was not in focus) and all are on non-rooted phones.

Traceback below:

Fatal Exception: java.lang.AssertionError
       at com.google.gson.internal.bind.TypeAdapters$EnumTypeAdapter.(Unknown Source)
       at com.google.gson.internal.bind.TypeAdapters$26.create(Unknown Source)
       at com.google.gson.Gson.getAdapter(Unknown Source)
       at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldAdapter(Unknown Source)
       at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.access$100(Unknown Source)
       at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.(Unknown Source)
       at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(Unknown Source)
       at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(Unknown Source)
       at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(Unknown Source)
       at com.google.gson.Gson.getAdapter(Unknown Source)
       at com.google.gson.internal.bind.CollectionTypeAdapterFactory.create(Unknown Source)
       at com.google.gson.Gson.getAdapter(Unknown Source)
       at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldAdapter(Unknown Source)
       at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.access$100(Unknown Source)
       at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.(Unknown Source)
       at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(Unknown Source)
       at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(Unknown Source)
       at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(Unknown Source)
       at com.google.gson.Gson.getAdapter(Unknown Source)
       at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldAdapter(Unknown Source)
       at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.access$100(Unknown Source)
       at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.(Unknown Source)
       at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(Unknown Source)
       at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(Unknown Source)
       at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(Unknown Source)
       at com.google.gson.Gson.getAdapter(Unknown Source)
       at com.google.gson.Gson.fromJson(Unknown Source)
       at com.google.gson.Gson.fromJson(Unknown Source)
       at com.google.gson.Gson.fromJson(Unknown Source)
       at com.google.gson.Gson.fromJson(Unknown Source)
       at io.smooch.core.facade.impl.a.a(Unknown Source)
       at io.smooch.core.facade.i.a(Unknown Source)
       at io.smooch.core.facade.impl.f.run(Unknown Source)
       at android.os.Handler.handleCallback(Handler.java:739)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:145)
       at android.app.ActivityThread.main(ActivityThread.java:5832)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:372)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)

@jugarrit
Copy link
Contributor

On which device?

@nizamsp
Copy link

nizamsp commented May 25, 2016

Its happening mainly in Samsung Phones.

sm_g900h - 35%
sm_n900 - 27%
sm_a500g - 24%

Can you please reopen this issue.

@dmitrikudrenko
Copy link
Author

@nizamsp check your proguard. It solved my problem.

@nizamsp
Copy link

nizamsp commented May 25, 2016

Thank you @dmitrikudrenko. My Proguard is like the following. Am I missing something here.

-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keep public class * implements java.io.Serializable
-keep public class * extends android.support.v4.app.Fragment
-keep public class * extends android.support.v4.app.ListFragment



-keep public class org.spongycastle.** {
  <fields>;
  <methods>;
}

-keep public class org.apache.** {
  <fields>;
  <methods>;
}

-ignorewarnings

-keepclasseswithmembernames class * {
    native <methods>;
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers class * extends android.app.Activity {
   public void *(android.view.View);
}


-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

-keepclassmembers class * implements java.io.Serializable {
    static final long serialVersionUID;
    private static final java.io.ObjectStreamField[] serialPersistentFields;
    private void writeObject(java.io.ObjectOutputStream);
    private void readObject(java.io.ObjectInputStream);
    java.lang.Object writeReplace();
    java.lang.Object readResolve();
}

-keep public class * extends android.app.Fragment

-keep class de.greenrobot.** {*;}

-keepclassmembers class ** {
    public void onEvent*(**);
}

-keep class com.google.gson.** { *; }
-keep class com.google.inject.** { *; }
-keep class org.apache.http.** { *; }
-keep class org.apache.james.mime4j.** { *; }
-keep class javax.inject.** { *; }
-keep class retrofit.** { *; }
-keep class com.whereismytrain.** { *; }
-keep class com.uberapi.** { *; }
-keep class com.ubermodel.** { *; }
-keep class com.wimtwear.** { *; }
-dontwarn rx.**
-keep class com.example.testobfuscation.** { *; }
-keepattributes Signature
-keep class sun.misc.Unsafe { *; }
-keepclassmembers enum * { *; }

-keepattributes *Annotation*,SourceFile,LineNumberTable

@nizamsp
Copy link

nizamsp commented Sep 3, 2016

Why was this issue closed when its not resolved?
Your demo app itself is not using proguard.
I recommend using minifyEnabled True and then generate a release apk and then try the app.
Debug builds will work fine.

https://github.com/smooch/smooch-android/blob/master/demo/gradle/app/build.gradle

Following link has "ProGuard configuration for libraries" section.

https://medium.com/google-developers/smallerapk-part-2-minifying-code-554560d2ed40#.arkp4b5u4
Ideally we shouldn't be adding any proguard files and the library should have added this.

@skolarianer
Copy link

The following does the trick for me...
Found here.

-dontwarn okio.**
-keep class com.google.gson.** { *; }
-keepclassmembers enum * { *; }
-keepattributes Signature
-keepattributes *Annotation*

But I agree to @nizamsp. This should be done in the library.

@nizamsp
Copy link

nizamsp commented Sep 4, 2016

Yes. I am missing the following one in my progaurd.
-keepclassmembers enum * { *; }

@jugarrit jugarrit reopened this Sep 6, 2016
@jugarrit jugarrit added the bug label Sep 6, 2016
@jugarrit
Copy link
Contributor

jugarrit commented Sep 6, 2016

Just pushed a proguard fix in 4.0.5
Hope that helps :)

@jugarrit jugarrit closed this as completed Sep 6, 2016
@skolarianer
Copy link

Which rules have you implemented? It keeps crashing when I remove the rules mentioned above from my proguard config.

@jugarrit
Copy link
Contributor

jugarrit commented Sep 6, 2016

-dontwarn okio.**
-keep class com.google.gson.** { *; }
-keepattributes Signature
-keepattributes *Annotation*
-keepclassmembers enum io.smooch.core.model.** { *; }

I tried this with minifyEnabled and it worked.

@skolarianer
Copy link

Ok, strange. These settings are not fetched. At least for me.

@skolarianer
Copy link

skolarianer commented Sep 6, 2016

I can't find any proguard configuration in your 'aar'.

noproguard2

@jugarrit jugarrit reopened this Sep 6, 2016
@jugarrit
Copy link
Contributor

jugarrit commented Sep 6, 2016

@skolarianer Sorry about that...

I was under the impression I didn't need to provide consumerProguardFiles for Smooch to function correctly if I had these settings in our proguard file, but I now realize my error.

I will be sure to fix this in the coming days.

@skolarianer
Copy link

skolarianer commented Sep 6, 2016

-keepclassmembers enum io.smooch.core.model.** { *; } seems to be not enough. I still need to add -keepclassmembers enum * { *; }. Otherwise the AssertionError will be thrown again.

java.lang.AssertionError
    at com.google.gson.internal.bind.TypeAdapters$EnumTypeAdapter.<init>(Unknown Source)

I tried to add -keepclassmembers enum com.google.gson.** { *; } only, but that didn't help.

@jugarrit
Copy link
Contributor

jugarrit commented Sep 6, 2016

Thanks for all the help!

@wmora
Copy link
Contributor

wmora commented Nov 10, 2017

proguard rules are included with the SDK since version 5.0.0

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

No branches or pull requests

5 participants