2016-10-26 2 views
0

私のプロジェクトをAPI 23にアップグレードしています。アプリ23はAPI 23でアプリ内課金でクラッシュしましたが、API 22で動作します。 launchPurchaseFlowメソッド。ここで In App BillingがAPI 23でクラッシュしました

private Context mContext; 
private IabHelper billinHelper; 
public InappPurchaseHandler(Context context) { 
     this.mContext = context; 
     billinHelper = new IabHelper(context, AppPropertyKey.BASE_64_KEY); 
     Toast.makeText(context.getApplicationContext(),"IABHEPLER",Toast.LENGTH_SHORT).show(); 

    } 

public void setonsetupCompleteListener(IabHelper.OnIabSetupFinishedListener listener){ 
     billinHelper.startSetup(listener); 
    } 


public void OnItemInventoryAsyn(IabHelper.QueryInventoryFinishedListener listener){ 

     billinHelper.queryInventoryAsync(listener); 
    } 
public void PurchaseItem(String sku,IabHelper.OnIabPurchaseFinishedListener listener){ 
     //if(billinHelper.isSetupDone() && !billinHelper.isAsyncInProgress())//change 
     if (billinHelper!=null) 
     billinHelper.launchPurchaseFlow((Activity) mContext, sku, IabHelper.ITEM_TYPE_SUBS, 123, listener, ""); 
    } 


public void OnBillingActivityResult(int requestCode,int resultCode,Intent data){ 
     billinHelper.handleActivityResult(requestCode, resultCode, data); 
    } 
public void disposeBillingHelper() { 
      if (billinHelper != null) { 
       billinHelper.dispose(); 
      } 
      billinHelper = null; 
     } 

iは関数を呼び出すコードです:ここで
--------- beginning of crash 
10-26 13:24:12.048 3031-3031/com.example.--- E/AndroidRuntime: FATAL EXCEPTION: main 
    Process: com.example.---, PID: 3031 
    java.lang.IllegalStateException: IAB helper is not set up. Can't perform operation: launchPurchaseFlow 
     at com.android.vending.billing.util.IabHelper.checkSetupDone(IabHelper.java:790) 
     at com.android.vending.billing.util.IabHelper.launchPurchaseFlow(IabHelper.java:380) 
     at com.MyQalam.InappPurchase.InappPurchaseHandler.PurchaseItem(InappPurchaseHandler.java:31) 
     at com.MyQalam.ShalatIndonesian.IndexActivity.onMenuItemSelected(IndexActivity.java:95) 
     at com.android.internal.policy.PhoneWindow.onMenuItemSelected(PhoneWindow.java:1151) 
     at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:761) 
     at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:152) 
     at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:904) 
     at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:894) 
     at com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:468) 
     at com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:129) 
     at android.view.View$PerformClick.run(View.java:21147) 
     at android.os.Handler.handleCallback(Handler.java:739) 
     at android.os.Handler.dispatchMessage(Handler.java:95) 
     at android.os.Looper.loop(Looper.java:148) 
     at android.app.ActivityThread.main(ActivityThread.java:5417) 
     at java.lang.reflect.Method.invoke(Native Method) 
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

は私のコードです

purchaseHandler.PurchaseItem(RemoveAds.SKU, 
        new OnIabPurchaseFinishedListener() { 
         @Override 
         public void onIabPurchaseFinished(IabResult result, 
                  Purchase info) { 
          if (result.isSuccess()) { 
           dataManager.setRemoveAds(true); 
           Toast.makeText(IndexActivity.this, 
             "Ads Successfully Removed.", 
             Toast.LENGTH_LONG).show(); 
           RefrshActivity(); 
          } 
         } 
        }); 

答えて

0

そのソリューションの男:

@Override 
protected void onActivityResult(int requestCode, int resultCode, Intent data) { 

      purchaseHandler.OnBillingActivityResult(requestCode,resultCode,data)); 
} 
0

私はクラッシュを引き起こすエミュレータ上でアプリ内課金をテストしていました。アプリ内課金はエミュレータでテストされません:

  1. あなたの本当のAndroidデバイスは、サインapkで。
  2. あなたのAndroidデベロッパーアカウントでもう一度サインアドをアップロードしてテストしてください。
関連する問題