0
我搜索了幾個小時試圖弄清楚這一點。這是我迄今爲止所做的。 (注:我在Android Studio中開發)IAB安裝程序永不完成
- 生成APK簽署並上傳到由應用內產品我的開發者控制檯
- 並激活它
- 新增開票權限我的清單
- 廣泛梳理堆棧試圖找到類似的問題。
基本上在logcat中,我看到IABHelper開始安裝,但從未在任何時候完成。 (聽衆從來沒有得到一個回調)
private static final String TAG = "Preference Activity";
private static final String SKU_PRO = "desk.clock.pro.license";
static final int RC_REQUEST = 10001;
IabHelper mHelper;
private boolean mIsPremium;
private ArrayList<Preference> proSettings;
IInAppBillingService mService;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
bindService(new
Intent("com.android.vending.billing.InAppBillingService.BIND"),
mServiceConn, Context.BIND_AUTO_CREATE);
proSettings = new ArrayList<Preference>();
ActionBar b = getActionBar();
b.setDisplayHomeAsUpEnabled(true);
colorListener();
textureListener();
bgColorListener();
onPresetListener();
gradListener();
String base64Key = "[my key from dev console]";
bindService(new
Intent("com.android.vending.billing.InAppBillingService.BIND"),
mServiceConn, Context.BIND_AUTO_CREATE);
mHelper = new IabHelper(this, base64Key);
mHelper.enableDebugLogging(true);
Log.d(TAG, "Starting setup");
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, "Setting up success");
Log.d(TAG, "querying inventory");
mHelper.queryInventoryAsync(mGotInventoryListener);
Log.d(TAG, "queried");
}
});
IabHelper.QueryInventoryFinishedListener mGotInventoryListener
= new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result,
Inventory inventory) {
if (result.isFailure()) {
// handle error here
mIsPremium = false;
disableProAndRevertSettings();
}
else {
// does the user have the premium upgrade?
mIsPremium = inventory.hasPurchase(SKU_PRO);
if(mIsPremium) {
enableProSettings();
}else {
disableProAndRevertSettings();
}
}
}
};
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);
}
};
//rest of my activity
我得到了我的logcat的這條線,但從來沒有任何這 10-06 15後:46:44.485 20787-20787/com.ssa.digitaldeskclock d/IabHelper:啓動應用內結算設置。
你正在一個實際的設備上測試?這不適用於模擬器。 – Tenfour04
是的,我一直在使用我的開發人員帳戶登錄的HTC帳戶進行測試。 – Stephen