Recently I have updated my app to the latest Google Play Billing Library (7.1.1). After that I see multiple crash in Firebase crashlytics for users with Android 6 and 5 when they try to initiate billing flow process:
Fatal Exception: java.lang.NoSuchMethodError No virtual method stream()Ljava/util/stream/Stream; in class Ljava/util/AbstractCollection; or its super classes (declaration of 'java.util.AbstractCollection' appears in /system/framework/core-libart.jar)
com.android.billingclient.api.BillingFlowParams.zzq (com.android.billingclient:billing@@7.1.1:21) com.android.billingclient.api.BillingClientImpl.launchBillingFlow (com.android.billingclient:billing@@7.1.1:133)
/**
* Launch the billing flow
*/
public void launchBillingFlow(SkuDetails skuDetails) {
Log.d(TAG, "launchBillingFlow()");
if (null != skuDetails) {
BillingFlowParams.Builder billingFlowParamsBuilder = BillingFlowParams.newBuilder();
billingFlowParamsBuilder.setSkuDetails(skuDetails);
BillingResult br = mBillingClient.launchBillingFlow(this, billingFlowParamsBuilder.build());
if (br.getResponseCode() == BillingClient.BillingResponseCode.OK) {
mBillingFlowInProcess = true;
} else {
Log.d(TAG, "Billing failed: + " + br.getDebugMessage());
}
}
}
Anybody has the same problem? Maybe there is any solution to this problem?
P.S. I have added the following in proguard file but it didnt help:
-keep class com.android.vending.billing.**
This issue only occurs in Play Billing Library 7.1.1. It does not occur in Play Billing Library 7.0.0.
If you don't need the features of PBL 7.1.1, you can use PBL 7.0.0 and wait for a fixed version from Google.
This issue has also been reported in the issue tracker, but there has been no official response yet.
[Play Billing Library 7.1.1] launchBillingFlow() does not work on Android 6 (Marshmallow)
As @Robert mentioned, Play Billing Library 7.1.1 seems to use classes available starting with Android 7 (Java 8).
Luckily, we have an Android 6 test device. We tested it by turning on the desugaring option in build.gradle.kts as below and confirmed that the issue is resolved.
I think this should be documented in the Play Billing Library 7.1.1 release notes.
build.gradle.kts
android {
...
compileOptions {
isCoreLibraryDesugaringEnabled = true
}
}
dependencies {
...
implementation( "com.android.billingclient:billing:7.1.1" )
coreLibraryDesugaring( "com.android.tools:desugar_jdk_libs:2.1.2" )
}
Further investigations
BillingFlowParams.Builder.build() calls this.zzc.forEach(new zzce()); for null check