Trivial Drive Kotlin
- Checkout the following repo: https://github.com/android/play-billing-samples
- Open the project "TrivialDriveKotlin" in Android Studio
- Replace the billing library reference in
TrivialDriveKotlin/app/build.gradle
for our library that you can get here:....
implementation "com.android.billingclient:billing-ktx:$version_billing"
for:
releaseImplementation "com.android.billingclient:billing:$version_billing"
debugImplementation "dev.iap.android.billingclient-ktx:billing_5_1:1.0.0"
- Add the following:
android.jetifier.blacklist=bcprov
. Souce: https://github.com/robolectric/robolectric/issues/6521
This method has been deprecated since v4.0.0 In that same file, add the following in line 752:
case 0: // Pull request submitted: https://github.com/android/play-billing-samples/issues/465
br = billingClient.launchBillingFlow(activity,
billingFlowParamsBuilder.build());
if (br.getResponseCode() == BillingClient.BillingResponseCode.OK) {
billingFlowInProcess.postValue(true);
} else {
Log.e(TAG, "Billing failed: + " + br.getDebugMessage());
}
Replace jcenter()
for mavenCentral()
In the AndroidManifest.xml
file,
<activity
android:name="com.sample.android.trivialdrivesample.ui.MainActivity"
android:label="@string/title_game_fragment"
android:exported="true"> <!-- Add this attribute if compiling with newer version of Android -->
Change the key : base64EncodedPublicKey="null"
in local.properties
to the value you can download from the console under:
/organizations/{your org}/projects/{your project}/android
make sure you use the Public key. Use the Copy to clipboard icon which will give you the value with no line breaks and no header and footer
which is the expected way
Initialize the Iap SDK in the BillingDataSource
's constructor just before the BillingClient is being constructed.