Q:

How to set up ProGuard for Amazon IAP?

I'm trying to set up a basic ProGuard with Amazon IAP integrated. However when I'm trying to export my APK, I got the following errors:
[2012-06-17 10:59:44 - sc] Proguard returned with error code 1. See console
[2012-06-17 10:59:44 - sc] Unexpected error while performing partial evaluation:
[2012-06-17 10:59:44 - sc]   Class       = [com/amazon/inapp/purchasing/KiwiResponseHandler$PurchaseResponseHandlerRunnable]
[2012-06-17 10:59:44 - sc]   Method      = [run()V]
[2012-06-17 10:59:44 - sc]   Exception   = [java.lang.IllegalArgumentException] (Can't find common super class of [java/lang/String] (with 4 known super classes) and [com/amazon/inapp/purchasing/KiwiPurchaseResponseCommandTask] (with 1 known super classes))
[2012-06-17 10:59:44 - sc] java.lang.IllegalArgumentException: Can't find common super class of [java/lang/String] (with 4 known super classes) and [com/amazon/inapp/purchasing/KiwiPurchaseResponseCommandTask] (with 1 known super classes)
[2012-06-17 10:59:44 - sc]  at proguard.evaluation.value.ReferenceValue.generalize(ReferenceValue.java:344)
[2012-06-17 10:59:44 - sc]  at proguard.evaluation.value.IdentifiedReferenceValue.generalize(IdentifiedReferenceValue.java:65)
[2012-06-17 10:59:44 - sc]  at proguard.evaluation.value.ReferenceValue.generalize(ReferenceValue.java:481)
...

I have the default ProGuard configuration file, and I have already added the:
 -dontwarn com.amazon.**
 -keep class com.amazon.** {*;}
 -keepattributes *Annotation*

lines to it. Any suggestion what went wrong?

A:

There is some fishy stuff with the recommended config of Amazon.
1) -dontwarn is hiding a deeper underlying issue, where some Amazon specific libraries are not present, but referenced so that proguard will try some wired optimization which likely causes the above mentioned stacktrace.
2) -dontoptimize is disabling all optimizations, which is defenitivly wrong, because it is most probably just one specific optimization which is causing this issue, and proguards optimizations are removing alot of dead and unused code from your app and its libraries, so it shrinks the total dex size. 
I guess fixing 1) is the real solution. This could be eventually achieved by extracting Amazons system libs from a device and make them present (as a provided lib) while building
the app. 
For 2) you can try:
-dontwarn com.amazon.**
-keep class com.amazon.** {
    *;
}

-optimizations !code/allocation/variable

which solved the issue for me.

A:

Per Amazon's SDK Docs, here are the lines you should include:
Preventing Obfuscation of In-App Purchasing API
When incorporating the In-App Purchasing API into your library, you will need to specify classes to 'keep' and not obfuscate. Add the following lines anywhere in your proguard.cfg file.
-dontwarn com.amazon.**
-keep class com.amazon.** {*;}
-keepattributes *Annotation*

In addition, you will also need to skip Proguard's optimization step.
-dontoptimize

Note: Make sure to remove any other flags dealing with optimization, or any flag that may conflict with the above settings.

