3

Using the Stripe library and sample located here. When I attempt to create a token in the release version of our app I get the following stacktrace:

    java.lang.RuntimeException: An error occured while executing doInBackground()
    at com.stripe.android.compat.AsyncTask$3.done(AsyncTask.java:250)
    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
    at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
    at java.util.concurrent.FutureTask.run(FutureTask.java:242)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
    at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.ExceptionInInitializerError
    at com.stripe.net.APIResource.<clinit>(APIResource.java:37)
    at com.stripe.android.Stripe$1$1.doInBackground(Stripe.java:28)
    at com.stripe.android.Stripe$1$1.doInBackground(Stripe.java:23)
    at com.stripe.android.compat.AsyncTask$2.call(AsyncTask.java:236)
    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
    ... 3 more
Caused by: java.lang.RuntimeException: Missing type parameter.
    at com.google.a.c.a.getSuperclassTypeParameter(TypeToken.java:84)
    at com.google.a.c.a.<init>(TypeToken.java:62)
    at com.stripe.model.FeeRefundCollectionDeserializer$1.<init>(FeeRefundCollectionDeserializer.java:17)
    at com.stripe.model.FeeRefundCollectionDeserializer.<clinit>(FeeRefundCollectionDeserializer.java:17)
    ... 8 more

Seems to work fine using a debug build. I am using proguard and have added the exclusion noted in the docs:

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

The card I'm using is a test one which gracefully tells me it's a test card being used with a live key when I run a debug apk. When I attempt the same in a live apk it produces this crash.

Testing without any proguard at all now...

EDIT:

Okay I have turned off proguard completely and it seems to have made the issue go away. So now I'll try and dig around with my extremely limited proguard knowledge to try and figure out what's going on here :)

Here is my full proguard-rules.pro file:

-dontwarn com.facebook.**
-dontwarn org.joda.time.**
-dontwarn org.codehaus.**
-dontwarn java.nio.**
-dontnote **ILicensingService
-keep class com.crashlytics.** { *; }
-keep class com.crashlytics.android.**
-keep class com.stripe.** { *; }
-keepattributes SourceFile,LineNumberTable,*Annotation*
Daniel Wilson
  • 18,838
  • 12
  • 85
  • 135

1 Answers1

1

After quite a bit of searching I've learned that proguard seems to be stripping out Gson related classes in the Stripe library even when it shouldn't.

As posted here, Google seems to recommend some additional proguard settings for gson:

-dontwarn com.facebook.**
-dontwarn org.joda.time.**
-dontwarn org.codehaus.**
-dontwarn java.nio.**
-dontnote **ILicensingService
-keep class com.crashlytics.** { *; }
-keep class com.crashlytics.android.**
-keep class com.stripe.** { *; }
##---------------Begin: proguard configuration for Gson  ----------
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature

# For using GSON @Expose annotation
-keepattributes *Annotation*

# Gson specific classes
-keep class sun.misc.Unsafe { *; }

##---------------End: proguard configuration for Gson  ----------
-keepattributes SourceFile,LineNumberTable

Adding these settings to proguard seems to have fixed the release build of my app.

Community
  • 1
  • 1
Daniel Wilson
  • 18,838
  • 12
  • 85
  • 135