Android IAB 错误 - 需要身份验证
Android IAB Error - Authentication required
我在我的应用程序中测试 App Billing ()v3 时遇到问题,我无法使用测试帐户购买任何东西。它总是向我显示
的 Play 商店对话框
"Error Authentication is required. You must log in with your Google Account"
我只能毫无问题的购买预留商品"android.test.purchased"消费
IAB 开始:
private static final int REQ_CODE_BUY = 51667;
private static final String buyFile = "bought";
private Activity activity;
private ProgressDialog pD;
private IInAppBillingService mService;
private ServiceConnection mServiceConn = new ServiceConnection() {
@Override
public void onServiceDisconnected(ComponentName name) {
mService = null;
}
@Override
public void onServiceConnected(ComponentName name,
IBinder service) {
mService = IInAppBillingService.Stub.asInterface(service);
}
};
public IABHelper(Activity activity, ProgressDialog pD){
this.activity = activity;
this.pD = pD;
}
public void start(){
Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
serviceIntent.setPackage("com.android.vending");
activity.bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE);
}
public void destroy(){
if (mService != null) {
activity.unbindService(mServiceConn);
}
}
IAB 购买和消费:
public void buy(String sku){
try {
Bundle buyIntentBundle = mService.getBuyIntent(3, activity.getPackageName(), sku, "inapp", devPayload);
//Bundle buyIntentBundle = mService.getBuyIntent(3, activity.getPackageName(), "android.test.purchased", "inapp", devPayload);
PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
if(pendingIntent != null){
activity.startIntentSenderForResult(pendingIntent.getIntentSender(), REQ_CODE_BUY, new Intent(), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0));
pD.show();
}
else{
Toast.makeText(activity, R.string.error, Toast.LENGTH_LONG).show();
}
} catch (RemoteException e) {
e.printStackTrace();
} catch (SendIntentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void consume(final String purchaseToken){
Thread consumeThread = new Thread(new Runnable(){
@Override
public void run() {
try {
int response = mService.consumePurchase(3, activity.getPackageName(), purchaseToken);
//int response = mService.consumePurchase(3, activity.getPackageName(), "inapp:com.mumble.artplace:android.test.purchased");
Log.d("response", Integer.toString(response));
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
consumeThread.start();
}
处理购买响应:
public void resolveResponse(int requestCode, int resultCode, Intent data){
if(requestCode == REQ_CODE_BUY){
if(resultCode == Activity.RESULT_OK){
int responseCode = data.getIntExtra("RESPONSE_CODE", 0);
String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA");
String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE");
JSONObject jData;
try {
if(responseCode == 0){
jData = new JSONObject(purchaseData);
String purchaseToken = jData.getString("purchaseToken");
String developerPayload = jData.getString("developerPayload");
if(developerPayload.equals(devPayload))){
consume(purchaseToken);
}
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
pD.dismiss();
}
else{
if(resultCode == Activity.RESULT_CANCELED){
pD.dismiss();
}
}
}
}
发生这种情况时,我单击 "OK" 它只有 returns 一个 responseCode RESULT_CANCEL 和一个带有空额外内容的 Intent。
我已经尝试从我的设备中删除所有帐户,只留下开发人员帐户,只留下测试帐户,并尝试使用其他手机但没有成功。我真的不知道我哪里错了...
请帮助我,谢谢
Soomla IAB error while purchasing in Game on Android
这是我的问题,我认为是同样的问题,所以,
问题出在 Google 开发者控制台上,为了购买,您必须发布 apk,即使它是 Beta 或 Alpha,之后,您可以使用测试人员批准的帐户进行测试。
在我的例子中,这是产品 ID 的错误,来自 Play 商店和应用内的产品 ID SKU_NAME 应该与应用内结算相同。
iab示例项目中没有正确提及哪个是productId
即SKU_GAS="gas"和SKU_PREMIUM="premium"项目
然后
"gas" 和 "premium" 必须作为 productId 在 play-store 上可用.
我在我的应用程序中测试 App Billing ()v3 时遇到问题,我无法使用测试帐户购买任何东西。它总是向我显示
的 Play 商店对话框"Error Authentication is required. You must log in with your Google Account"
我只能毫无问题的购买预留商品"android.test.purchased"消费
IAB 开始:
private static final int REQ_CODE_BUY = 51667;
private static final String buyFile = "bought";
private Activity activity;
private ProgressDialog pD;
private IInAppBillingService mService;
private ServiceConnection mServiceConn = new ServiceConnection() {
@Override
public void onServiceDisconnected(ComponentName name) {
mService = null;
}
@Override
public void onServiceConnected(ComponentName name,
IBinder service) {
mService = IInAppBillingService.Stub.asInterface(service);
}
};
public IABHelper(Activity activity, ProgressDialog pD){
this.activity = activity;
this.pD = pD;
}
public void start(){
Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
serviceIntent.setPackage("com.android.vending");
activity.bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE);
}
public void destroy(){
if (mService != null) {
activity.unbindService(mServiceConn);
}
}
IAB 购买和消费:
public void buy(String sku){
try {
Bundle buyIntentBundle = mService.getBuyIntent(3, activity.getPackageName(), sku, "inapp", devPayload);
//Bundle buyIntentBundle = mService.getBuyIntent(3, activity.getPackageName(), "android.test.purchased", "inapp", devPayload);
PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
if(pendingIntent != null){
activity.startIntentSenderForResult(pendingIntent.getIntentSender(), REQ_CODE_BUY, new Intent(), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0));
pD.show();
}
else{
Toast.makeText(activity, R.string.error, Toast.LENGTH_LONG).show();
}
} catch (RemoteException e) {
e.printStackTrace();
} catch (SendIntentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void consume(final String purchaseToken){
Thread consumeThread = new Thread(new Runnable(){
@Override
public void run() {
try {
int response = mService.consumePurchase(3, activity.getPackageName(), purchaseToken);
//int response = mService.consumePurchase(3, activity.getPackageName(), "inapp:com.mumble.artplace:android.test.purchased");
Log.d("response", Integer.toString(response));
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
consumeThread.start();
}
处理购买响应:
public void resolveResponse(int requestCode, int resultCode, Intent data){
if(requestCode == REQ_CODE_BUY){
if(resultCode == Activity.RESULT_OK){
int responseCode = data.getIntExtra("RESPONSE_CODE", 0);
String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA");
String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE");
JSONObject jData;
try {
if(responseCode == 0){
jData = new JSONObject(purchaseData);
String purchaseToken = jData.getString("purchaseToken");
String developerPayload = jData.getString("developerPayload");
if(developerPayload.equals(devPayload))){
consume(purchaseToken);
}
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
pD.dismiss();
}
else{
if(resultCode == Activity.RESULT_CANCELED){
pD.dismiss();
}
}
}
}
发生这种情况时,我单击 "OK" 它只有 returns 一个 responseCode RESULT_CANCEL 和一个带有空额外内容的 Intent。 我已经尝试从我的设备中删除所有帐户,只留下开发人员帐户,只留下测试帐户,并尝试使用其他手机但没有成功。我真的不知道我哪里错了... 请帮助我,谢谢
Soomla IAB error while purchasing in Game on Android 这是我的问题,我认为是同样的问题,所以, 问题出在 Google 开发者控制台上,为了购买,您必须发布 apk,即使它是 Beta 或 Alpha,之后,您可以使用测试人员批准的帐户进行测试。
在我的例子中,这是产品 ID 的错误,来自 Play 商店和应用内的产品 ID SKU_NAME 应该与应用内结算相同。
iab示例项目中没有正确提及哪个是productId
即SKU_GAS="gas"和SKU_PREMIUM="premium"项目
然后
"gas" 和 "premium" 必须作为 productId 在 play-store 上可用.