Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] kotlin – Could not compute caller for function: public constructor Error when enable proguard in Android

Posted on November 11, 2022 By

Solution 1 :

Solved by adding these rules

-keepclassmembers class kotlin.Metadata {
    public <methods>;
}

-keepclassmembers class * {
    @com.squareup.moshi.FromJson <methods>;
    @com.squareup.moshi.ToJson <methods>;
}

-keepnames @kotlin.Metadata class com.******.domain.entities.**
-keep class com.******.domain.entities.** { *; }
-keepclassmembers class com.*****.domain.entities.** { *; }

The problem was in Moshi library, check this

Problem :

The project working well without enabling proguard, the problem comes when enable it, I am using retrofit with Moshi converter and Coroutines to fetch list of data, and Hilt for DI, and I added all rules and kept all models

This is the error:

Could not compute caller for function: public constructor MovieListEntity(movie_data: kotlin.collections.List<com...domain.entities.MovieData>) defined in com...domain.entities.MovieListEntity[[email protected]] (member = null)

And these are the classes mentioned

data class MovieListEntity(
     @field:Json(name = "movie_data")
     val movie_data: List<MovieData>
)
data class MovieData(
    @field:Json(name = "movie_id")
    val movie_id: Int,
    @field:Json(name = "sub_title")
    val sub_title: String,
    @field:Json(name = "title")
    val title: String
)

Note: I tried also without annotations, and it didn’t help

These are the proguard rules:

-keep class com.***.***.domain.entitie.** { *; }
-keep class com.***.***.domain.entities.*
-keep class com.***.***.domain.entities.MovieListEntity
-keep class com.***.***.domain.entities.MovieData

-keep class com.***.***.DataBinderMapperImpl { *; }
-keep class com.***.***.DataBinderMapperImpl { *; }
-keep  class com.***.*****{
    public ** component1();
  <fields>;
 }

Plus other rules for retrofit, OkHttp, hilt .. etc.

How Can I solve this error?

READ  [FIXED] android - Glide Transformation memory leak
Powered by Inline Related Posts
Android Tags:android, data-class, kotlin, proguard, security

Post navigation

Previous Post: [FIXED] java – is permission needed when choosing image from gallery on android?
Next Post: [FIXED] Android Java: How to get component in a custom view? (Trying to access components via findByViewId and get null)

Related Posts

[FIXED] Why does an Android App launch in the background when running from Android Studio? Android
[FIXED] Execute raw update query in Room Database Android
[FIXED] Compile android app with java 11 dependencies Android
[FIXED] Android Execution failed for task ‘:app:compileDebugJavaWithJavac’. – React Native Android
[FIXED] java – Animation not working in onLongClickListener Android
[FIXED] android – activity gets destroyed after inserting data in firebase Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • What color are dead flea eggs?
  • What is Indiana vine?
  • What’s the downside of a Chromebook?
  • Is phosphide the same as phosphorus?
  • Why do you need an S bend?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme