InappBilling 错误 - 需要身份验证。您需要登录您的 google 帐户
InappBilling Error- authentication is required. you need to sign into your google account
我正在尝试制作一个 inappbilling 演示。我按照这个 tutorial 来研究这个。
让我说说我完成这个任务所遵循的步骤
我使用了下面提到的代码
package com.ohn.inappbilling;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import com.hello.inappbilling.util.IabHelper;
import com.hello.inappbilling.util.IabResult;
import com.hello.inappbilling.util.Inventory;
import com.hello.inappbilling.util.Purchase;
import com.ohn.inappbilling.R;
public class MainActivity extends ActionBarActivity {
private static final String TAG = "com.hello.inappbilling";
static final String ITEM_SKU = "com.buttonclick";
IabHelper mHelper;
private Button clickButton;
private Button buyButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
buyButton = (Button) findViewById(R.id.buyButton);
clickButton = (Button) findViewById(R.id.clickButton);
clickButton.setEnabled(false);
String base64EncodedPublicKey = "******";
mHelper = new IabHelper(this, base64EncodedPublicKey);
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
if (!result.isSuccess()) {
Log.d(TAG, "In-app Billing setup failed: " + result);
} else {
Log.d(TAG, "In-app Billing is set up OK");
}
}
});
//throw new RuntimeException();
}
public void buttonClicked(View view) {
clickButton.setEnabled(false);
buyButton.setEnabled(true);
}
public void buyClick(View view) {
mHelper.launchPurchaseFlow(this, ITEM_SKU, 10001,
mPurchaseFinishedListener, "mypurchasetoken");
}
@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent data)
{
if (!mHelper.handleActivityResult(requestCode,
resultCode, data)) {
super.onActivityResult(requestCode, resultCode, data);
}
}
IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener
= new IabHelper.OnIabPurchaseFinishedListener() {
public void onIabPurchaseFinished(IabResult result,
Purchase purchase)
{
if (result.isFailure()) {
// Handle error
return;
}
else if (purchase.getSku().equals(ITEM_SKU)) {
consumeItem();
buyButton.setEnabled(false);
}
}
};
public void consumeItem() {
mHelper.queryInventoryAsync(mReceivedInventoryListener);
}
IabHelper.QueryInventoryFinishedListener mReceivedInventoryListener
= new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result,
Inventory inventory) {
if (result.isFailure()) {
// Handle failure
} else {
mHelper.consumeAsync(inventory.getPurchase(ITEM_SKU),
mConsumeFinishedListener);
}
}
};
IabHelper.OnConsumeFinishedListener mConsumeFinishedListener =
new IabHelper.OnConsumeFinishedListener() {
public void onConsumeFinished(Purchase purchase,
IabResult result) {
if (result.isSuccess()) {
clickButton.setEnabled(true);
} else {
// handle error
}
}
};
@Override
public void onDestroy() {
super.onDestroy();
if (mHelper != null) mHelper.dispose();
mHelper = null;
}
}
我使用 File-Export-AndroidProject 创建了 apk 并在 alphatesting 中上传了它。
我在 alpha 测试的管理测试人员列表中添加了用户(Google 组)。
我在应用内产品中添加了产品并为其指定了 id com.buttonclick
在具有测试访问权限的Gmail帐户的设置中,我也在这里添加了Gmail ID。 None的id是开发者id。
任何人都可以告诉这个问题的解决方案。我已经尝试了 Whosebug
.
上可用的所有解决方案
我找到了这个问题的解决方案。
我在 playstore 上发布了这个 apk,然后我从 playstore 下载了 apk,运行 它工作正常
我认为这个问题背后的原因是
我测试用的google账号可能不是主账号
我花了将近 2 周的时间来解决这个问题,当我意识到我实际上没有启用 Beta 测试时,我感到非常沮丧:
要启用它,请确保您确实选中了列表名称旁边的框。
我正在尝试制作一个 inappbilling 演示。我按照这个 tutorial 来研究这个。
让我说说我完成这个任务所遵循的步骤
我使用了下面提到的代码
package com.ohn.inappbilling; import android.content.Intent; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.util.Log; import android.view.View; import android.widget.Button; import com.hello.inappbilling.util.IabHelper; import com.hello.inappbilling.util.IabResult; import com.hello.inappbilling.util.Inventory; import com.hello.inappbilling.util.Purchase; import com.ohn.inappbilling.R; public class MainActivity extends ActionBarActivity { private static final String TAG = "com.hello.inappbilling"; static final String ITEM_SKU = "com.buttonclick"; IabHelper mHelper; private Button clickButton; private Button buyButton; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); buyButton = (Button) findViewById(R.id.buyButton); clickButton = (Button) findViewById(R.id.clickButton); clickButton.setEnabled(false); String base64EncodedPublicKey = "******"; mHelper = new IabHelper(this, base64EncodedPublicKey); mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { public void onIabSetupFinished(IabResult result) { if (!result.isSuccess()) { Log.d(TAG, "In-app Billing setup failed: " + result); } else { Log.d(TAG, "In-app Billing is set up OK"); } } }); //throw new RuntimeException(); } public void buttonClicked(View view) { clickButton.setEnabled(false); buyButton.setEnabled(true); } public void buyClick(View view) { mHelper.launchPurchaseFlow(this, ITEM_SKU, 10001, mPurchaseFinishedListener, "mypurchasetoken"); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (!mHelper.handleActivityResult(requestCode, resultCode, data)) { super.onActivityResult(requestCode, resultCode, data); } } IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() { public void onIabPurchaseFinished(IabResult result, Purchase purchase) { if (result.isFailure()) { // Handle error return; } else if (purchase.getSku().equals(ITEM_SKU)) { consumeItem(); buyButton.setEnabled(false); } } }; public void consumeItem() { mHelper.queryInventoryAsync(mReceivedInventoryListener); } IabHelper.QueryInventoryFinishedListener mReceivedInventoryListener = new IabHelper.QueryInventoryFinishedListener() { public void onQueryInventoryFinished(IabResult result, Inventory inventory) { if (result.isFailure()) { // Handle failure } else { mHelper.consumeAsync(inventory.getPurchase(ITEM_SKU), mConsumeFinishedListener); } } }; IabHelper.OnConsumeFinishedListener mConsumeFinishedListener = new IabHelper.OnConsumeFinishedListener() { public void onConsumeFinished(Purchase purchase, IabResult result) { if (result.isSuccess()) { clickButton.setEnabled(true); } else { // handle error } } }; @Override public void onDestroy() { super.onDestroy(); if (mHelper != null) mHelper.dispose(); mHelper = null; } }
我使用 File-Export-AndroidProject 创建了 apk 并在 alphatesting 中上传了它。
我在 alpha 测试的管理测试人员列表中添加了用户(Google 组)。
我在应用内产品中添加了产品并为其指定了 id com.buttonclick
在具有测试访问权限的Gmail帐户的设置中,我也在这里添加了Gmail ID。 None的id是开发者id。
任何人都可以告诉这个问题的解决方案。我已经尝试了 Whosebug
.
我找到了这个问题的解决方案。
我在 playstore 上发布了这个 apk,然后我从 playstore 下载了 apk,运行 它工作正常
我认为这个问题背后的原因是 我测试用的google账号可能不是主账号
我花了将近 2 周的时间来解决这个问题,当我意识到我实际上没有启用 Beta 测试时,我感到非常沮丧:
要启用它,请确保您确实选中了列表名称旁边的框。