Android的IAB错误 - 需要验证 [英] Android IAB Error - Authentication required
问题描述
我在我的应用程序有问题的测试在应用程序内结算()V3,我不能测试帐户买东西。它总是给我看了一个播放存储对话框以
I got a problem testing In App Billing ()v3 in my app, I can't buy anything with test accounts. It always shows me a Play Store dialog with
"Error Authentication is required. You must log in with your Google Account"
我只能买了保留项目android.test.purchased没有任何问题,并使用它。
I can only buy the reserved item "android.test.purchased" without any problem and consume it.
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购买和消费:
IAB buy and consume:
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();
}
拉手团购响应:
Handle buy response:
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();
}
}
}
}
在这种情况下,我点击确定它只返回响应code RESULT_CANCEL和空额外的意图。 我已经尝试过,从我的设备,并只留下开发商之一,仅测试那些删除所有的帐户,并与其他手机尝试没有成功。我真的不知道我在哪里错了? 请帮帮我,谢谢
When this happens and i click "OK" it only returns a responseCode RESULT_CANCEL and an Intent with empty extras. I already tried to remove all accounts from my device and leaving only the developer one, only the test ones and tried with other phones without any success. I really don't know where I am wrong... Please help me, thanks
推荐答案
<一个href="http://stackoverflow.com/questions/27934552/soomla-iab-error-while-purchasing-in-game-on-android/27954078#27954078">Soomla而购买IAB错误的游戏在Android 这是我的问题,我认为这是同样的问题,所以, 问题是谷歌开发者控制台上,为了买你必须发布的APK,即使它是一个测试版或阿尔法,以后,你可以用测试仪批准帐户测试。
Soomla IAB error while purchasing in Game on Android this was my question, i think is the same problem, so , the problem is on the Google developer console, in order to buy you must publish the apk ,even if it is a beta or Alpha, and after ,you can test with testers approved accounts.
这篇关于Android的IAB错误 - 需要验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!