1

I'm developing an android application using kotlin and everything was fine till now that I'm getting the java.lang.IllegalArgumentException: Invalid primitive conversion from long to int exception on some android devices.

The exception is occurring just in the release build of the application and unfortunately, I have no clue how to debug or properly analyze the stack trace to get to know the exact problem.

The stack trace is as below:

java.lang.IllegalArgumentException: Invalid primitive conversion from long to int
    at java.lang.reflect.Field.getInt(Field.java)
    at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:946)
    at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:360)
    at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1054)
    at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1384)
    at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461)
    at android.os.Parcel.writeSerializable(Parcel.java:1463)
    at android.os.Parcel.writeValue(Parcel.java:1416)
    at android.os.Parcel.writeArrayMapInternal(Parcel.java:686)
    at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1376)
    at android.os.Bundle.writeToParcel(Bundle.java:1079)
    at android.os.Parcel.writeBundle(Parcel.java:711)
    at android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:3216)
    at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3496)
    at android.os.Handler.handleCallback(Handler.java:742)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:157)
    at android.app.ActivityThread.main(ActivityThread.java:5653)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:746)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)

Any help would be appreciated.

15
  • Can you share the code? Commented Jan 17, 2022 at 14:34
  • 1
    Can you attach the java files, It looks like a java error, Possibly in java code somewhere, it is trying to int cast a long in the wrong way. Commented Jan 17, 2022 at 14:35
  • @SujalKumar I don't know which part of the code is causing the problem to share it. Commented Jan 17, 2022 at 14:42
  • 1
    @moghaf It would be helpful if you attach your kotlin classes then, It is very difficult to help without seeing any code. Commented Jan 17, 2022 at 14:48
  • 1
    @SujalKumar Your solution to disable proguard led me to remove proguard lines one by one(after library exclusion didn't solve the problem) to test if it gets to work and yes it worked. Thanks. Commented Jan 17, 2022 at 17:49

1 Answer 1

1

For anyone who may have this problem, in my case, it has been solved by removing -overloadaggressively from the proguard-rules.pro file.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.