2016-06-22 12 views
1

自分の携帯電話で「プレミアムバージョン」を購入できるアプリを作っていますが、別の携帯電話でボタンをクリックすると(アクティビティで)、このメッセージが表示されます:私は、私のアンドロイドアプリケーションでいくつかの問題がある、それを解決するには?

アプリケーションは、残念ながらこれはonCreate()メソッドのコードである

を停止しました。私は問題がそこにあると思うが、私はそれを解決する方法を知らない。

protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_selector); 
    Bundle s = getIntent().getExtras(); 
    int x = s.getInt("day"); 
    int y = s.getInt("month"); 
    int z = s.getInt("year"); 
    String base64EncodedPublicKey = "MY GOOGLE ID" 
    mHelper = new IabHelper(this, base64EncodedPublicKey); 


    // compute your public key and store it in base64EncodedPublicKey 
    mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { 
     public void onIabSetupFinished(IabResult result) { 
      if (!result.isSuccess()) { 
       // Oh noes, there was a problem. 
       Log.d(TAG, "Problem setting up In-app Billing: " + result); 
      } 

      Log.d(TAG, "Setup successful. Querying inventory."); 

      try { 
       mHelper.queryInventoryAsync(false,mGotInventoryListener); 
      } catch (IabHelper.IabAsyncInProgressException e) { 
       e.printStackTrace(); 
      } 
      // Hooray, IAB is fully set up! 
     } 
    }); 




} 

IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() { 
    public void onQueryInventoryFinished(IabResult result, 
             Inventory inventory) { 
     Log.d(TAG, "Query inventory finished."); 
     if (result.isFailure()) { 
      alert("Failed to query inventory: " + result); 
      return; 
     } 

     Log.d(TAG, "Query inventory was successful."); 

     // Do we have the premium upgrade? 
     mIsPremium = inventory.hasPurchase(SKU_PREMIUM); 
     if(mIsPremium) 
     { 
      updateUi(); 
     } 
     Log.d(TAG, "User is " + (mIsPremium ? "PREMIUM" : "NOT PREMIUM")); 

     Log.d(TAG, "Initial inventory query finished; enabling main UI."); 

    } 
}; 

これはlogatです:

com.skope.sebastian.horoscopo E/IabHelper: In-app billing error: Illegal state for operation (queryInventory): IAB helper is not set up. 
com.skope.sebastian.horoscopo D/AndroidRuntime: Shutting down VM 
com.skope.sebastian.horoscopo E/AndroidRuntime: FATAL EXCEPTION: main 
Process: com.skope.sebastian.horoscopo, PID: 6709 
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.skope.sebastian.horoscopo/botones.skope.Horoscopo.selector}: 
java.lang.IllegalStateException: IAB helper is not set up. Can't perform operation: queryInventory 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
at android.app.ActivityThread.-wrap11(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
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) 
Caused by: java.lang.IllegalStateException: IAB helper is not set up. Can't perform operation: queryInventory 
at botones.skope.Horoscopo.util.IabHelper.checkSetupDone(IabHelper.java:861) 
at botones.skope.Horoscopo.util.IabHelper.queryInventoryAsync(IabHelper.java:691) 
at botones.skope.Horoscopo.util.IabHelper.queryInventoryAsync(IabHelper.java:721) 
at botones.skope.Horoscopo.selector$1.onIabSetupFinished(selector.java:59) 
at botones.skope.Horoscopo.util.IabHelper.startSetup(IabHelper.java:306) 
at botones.skope.Horoscopo.selector.onCreate(selector.java:49) 
at android.app.Activity.performCreate(Activity.java:6237) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)  
at android.app.ActivityThread.-wrap11(ActivityThread.java)  
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)  
at android.os.Handler.dispatchMessage(Handler.java:102)  
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)  
+0

[この投稿を参照](http://stackoverflow.com/questions/23353173/unfortunately-myapp-has-stopped-how-can-i-solve-this)、[編集]のlogcat –

答えて

0

あなたのエラーの最も有用な部分は、あなたが正しくバックに活動結果を渡すように要求されinappBillingHelper.handleActivityResult(requestCode, resultCode, data)を実装していないことを示すことになるIAB helper is not set up. Can't perform operation: queryInventoryですアプリ課金ヘルパー私は、ドキュメントのどこかに完全な例があると確信しています。

関連する問題