Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
146 views
in Technique[技术] by (71.8m points)

java - Testing google subscription in android app not working

enter image description here

That is the error I am getting in log. I don't know what it means I have everytihng up to date. I am using Redmi Note 8 as testing device.

I have permission in manifest set as ""

I was following entire guide on their page how to set up app subscription and how to test it. Whole code is copied. On my brothers phone which is S10 Galaxy it just shows small dialog window but it does not show the item which he can purchase.

This is the class which I have created:

public class SubscriptionInitializer {
private BillingClient mBillingClient;
private PurchasesUpdatedListener mPurchasesUpdatedListener;



public SubscriptionInitializer(Context context){
    initPurchasesListener();
    buildBillingClient(context);
}


public void startBillingConnection(Context context){
    
    mBillingClient.startConnection(new BillingClientStateListener() {
        @Override
        public void onBillingSetupFinished(@NonNull BillingResult billingResult) {

            if (billingResult.getResponseCode() ==  BillingClient.BillingResponseCode.OK) {
                // The BillingClient is ready. You can query purchases here.

                Log.d("ARRAY", "Billing setupFinished");

                List<String> skuList = new ArrayList<>();
                skuList.add("inner_monthly_sub");
                SkuDetailsParams.Builder params = SkuDetailsParams.newBuilder();
                params.setSkusList(skuList).setType(BillingClient.SkuType.SUBS);
                mBillingClient.querySkuDetailsAsync(params.build(),
                        (billingResult1, skuDetailsList) -> {
                            // Retrieve a value for "skuDetails" by calling querySkuDetailsAsync().
                            BillingFlowParams billingFlowParams = BillingFlowParams.newBuilder()
                                    .setSkuDetails(skuDetailsList.get(0))
                                    .build();

                            int responseCode = mBillingClient.launchBillingFlow((Activity)context, billingFlowParams).getResponseCode();
                        });

            }
            else {
                Log.d("ARRAY", billingResult.getDebugMessage());
            }
        }
        @Override
        public void onBillingServiceDisconnected() {
            // Try to restart the connection on the next request to
            // Google Play by calling the startConnection() method.
            Log.d("ARRAY", "Billing disconnected");
            mBillingClient.startConnection(this);
        }
    });

}


private void initPurchasesListener(){

    mPurchasesUpdatedListener = (billingResult, purchases) -> {
        Log.d("ARRAY", "Purchase Listener initialization");
    };
}

private void buildBillingClient(Context context){
    mBillingClient = BillingClient.newBuilder(context)
            .setListener(mPurchasesUpdatedListener)
            .enablePendingPurchases()
            .build();
}

}

startBillingConnection method I call in MainActivity just after setContentView .

I have the app uploaded in Internal Testing in google play console and it is published there and I have set every email that I have as licensed emails.

Please help as google developer pages are unhelpful since every mail I've sent them they never responded and guides are outdated.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...