4

I recently added a library to my app ('GNSDK' by Gracenote) and am now trying to build the app for release using Proguard. I successfully built and installed the release version of the app once, but all subsequent attempts produce this error:

Unexpected error while evaluating instruction:
 Class       = [com/gracenote/gnsdk/GnManager]   
 Method      = [<init>(Landroid/content/Context;Ljava/lang/String;I)V]
 Instruction = [87] getfield #120
 Exception   = [java.lang.IllegalArgumentException] (Value "i" is not a 
  reference value [proguard.evaluation.value.UnknownIntegerValue])
  Unexpected error while performing partial evaluation:
    Class       = [com/gracenote/gnsdk/GnManager]
    Method      = [<init>(Landroid/content/Context;Ljava/lang/String;I)V]
    Exception   = [java.lang.IllegalArgumentException] (Value "i" is not a reference value [proguard.evaluation.value.UnknownIntegerValue])
  :app:proguardBetaRelease FAILED
  Error:Execution failed for task ':app:proguardBetaRelease'.

Value "i" is not a reference value [proguard.evaluation.value.UnknownIntegerValue]`

I tried to force proguard to leave the library alone (since that's the only difference between the debug and release builds) with:

-keep class com.gracenote.** {
    *;
}

but it does not seem to make a difference.

Any hints on how to debug or track down this error? I am not sure why the constructor of com.gracenote.gnsdk.GnManager would be failing. The error makes it sound like it is getting an invalid input.

I'm using Android Studio 1.4, build tools 23.0.0.

Lisa Wray
  • 2,242
  • 16
  • 23
  • 1
    Start by running gradle with --info or --debug, but TBH it looks like a bug in ProGuard, no amount of misconfiguration should cause ProGuard to crash and print out debug information. – Michał Bendowski Aug 25 '15 at 11:33
  • @MichalBendowski you were right and I eventually found the Proguard bug tracker :) – Lisa Wray Sep 16 '15 at 18:01

3 Answers3

16

I found that this is a bug in Proguard: https://sourceforge.net/p/proguard/bugs/573/

Looks like it will be released soon. In the meantime, you can work around by adding:

-optimizations !class/unboxing/enum

to your proguard file.

Lisa Wray
  • 2,242
  • 16
  • 23
0

For what it's worth, I found this for a java project. I was running proguard targeting 1.8 when it should have been 1.9. Once I changed it it worked.

CamHart
  • 3,825
  • 7
  • 33
  • 69
0

For anyone still facing this issue. In my case, I had the android.enableR8=false added to the gradle.properties file and removing this line fixed the issue.

However, it might be helpful only when using some older Android Gradle plugin version because this property is completely removed in 7.0 version:

The option setting 'android.enableR8=false' is deprecated. It will be removed in version 7.0 of the Android Gradle plugin. You will no longer be able to disable R8

Mieczkoni
  • 505
  • 2
  • 8