1

I know in Android Studio we can decompile Kotlin bytecode to Java from

Tools->Kotlin->Show Kotlin Bytecode

and then Decompile in the opened window. but the result is somehow messy. for example in this code, variable names are changed to var1,var2 and so on and missed Generic type in return value type.

the Kotlin code:

   @GET("webservicesample")
        fun advancedSearchCall(@Query("parms[catid]") catID: String,
                               @Query("parms[min]") minPrice: String,
                               @Query("parms[max]") maxPrice: String,
                               @Query("parms[brandid]") brandId: String,
                               @Query("parms[minpre]") minPrePay: String,
                               @Query("parms[maxpre]") maxPrePay: String,
                               @Query("parms[id]") lastResult: String,
                               @Query("parms[number]") number: String)
                : Call<AdvancedSearchResponse>

Decompiled to Java from bytecode:

@GET("webserviceexample")
       @NotNull  Call advancedSearchCall(
                  @Query("parms[catid]") @NotNull String var1, 
                  @Query("parms[min]") @NotNull String var2, 
                  @Query("parms[max]") @NotNull String var3, 
                  @Query("parms[brandid]") @NotNull String var4,
                  @Query("parms[minpre]") @NotNull String var5,
                  @Query("parms[maxpre]") @NotNull String var6,
                  @Query("parms[id]") @NotNull String var7,
                  @Query("parms[number]") @NotNull String var8);

I wonder if there is a way to prevent this and get clean Java code when decompiling from Kotlin?

Marzi Heidari
  • 2,660
  • 4
  • 25
  • 57

0 Answers0