stripe-android lib 1.0.3升级导致执行错误

stripe-android lib 1.0.3 upgrade causes execution error

我升级到最新的stripe-android lib: compile 'com.stripe:stripe-android:1.0.3'

这只需要我将货币添加到 Card 构造函数 ("USD"):

Card stripeCard = new Card(
  cardNumber, month, year, cvc, name,
  line1, line2, city, state, zip, "US", "USD"
);

但这会导致 Android Studio 在编译成功后出现执行错误:

当我降级到:compile 'com.stripe:stripe-android:1.0.0'

时,执行错误消失了

这是我的一部分 build.gradle:

compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "com.website.app"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 20
    versionName "1.0"
}

有什么想法吗?

货币不能作为参数传递给构造函数,但您可以使用卡片的生成器或通过显式设置 属性 来设置它,即

//using the Builder
Card card = new Card.Builder("4242424242424242", 9, 2018, "123").currency("usd").build();

//or set the property once you've created the card
card.setCurrency("usd")

看来我是第一次达到 65k 的限制。我的最终解决方案是包含我需要的 Google Play 服务的特定 API,而不是全部。在这里阅读更多:https://developers.google.com/android/guides/setup

运行 ./gradlew assemble --info 按照@Gabriele Mariotti 的建议帮助我提供了更详细的信息 "UNEXPECTED TOP-LEVEL DEX EXCEPTION"。有了这个,我遇到了这个post:Why did this happen? How do i fix this? Android: UNEXPECTED TOP-LEVEL EXCEPTION:, which directed me to this documentation https://developer.android.com/tools/building/multidex.html