1年以来、私はAndroidアプリを開発しています。次のステップに進み、課金システムを実装する時が来たと思いました。この新機能をメイン アプリに実装する前に、テストしたほうがよいと考えました。
先週、メイン アプリ (v3 課金システムなし) と同じアプリ (v3 課金システムあり) のテスト アプリを開発しました。私はそれを公開し、Google Play 経由で Samsung Note にインストールしました。購入して購読できていました。そして、それはうまくいきました。そこで、テスト アプリを非アクティブ化し、課金方法全体をメイン アプリにコピーし、Base64 でコード化された公開 RSA キーを変更して公開しました。
インストールして起動した後、毎回アプリがクラッシュしました。そして、最近のバージョンは課金システムがなくてもうまく機能するため、理由は課金システムだけです。もちろん、メインのアプリを、メインのアプリと同じように機能する新しいアプリに置き換えることもできますが、これまでのすべてのユーザー、統計、コメントが失われます。アプリが RSA キーを使用して課金システムをインストールできない理由を知っていますか? この状況の原因として、他にどのような理由が考えられますか?
onCreate で何が起こるか:
mHelper = new IabHelper(this, base64EncodedPublicKey);
// enable debug logging (for a production application, you should set this to false).
mHelper.enableDebugLogging(false);
// Start setup. This is asynchronous and the specified listener
// will be called once setup completes.
Log.d(TAG, "Starting setup.");
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
Log.d(TAG, "Setup finished.");
if (!result.isSuccess()) {
// Oh noes, there was a problem.
complain("Problem setting up in-app billing: " + result);
return;
}
// Hooray, IAB is fully set up. Now, let's get an inventory of stuff we own.
Log.d(TAG, "Setup successful. Querying inventory.");
mHelper.queryInventoryAsync(mGotInventoryListener);
}
});
960行目で何が起こるか:
public IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
Log.d(TAG, "Query inventory finished .");
if (result.isFailure()) {
complain("Failed to query inventory: " + result);
return;
}
Log.d(TAG, "Query inventory was successful.");
// Purchase premium monthly
Purchase purchase = inventory.getPurchase(Constants.PREMIUM);
if(purchase.getPurchaseState() == Purchase.PURCHASED_SUCCESSFULLY && verifyDeveloperPayload(purchase)){
isPremium = true;
}else{
isPremium = false;
updatePremium(purchase.getPurchaseState());
}
Log.d(TAG, "User " + (isPremium ? "HAS" : "DOES NOT HAVE") + " premium surebets for 32 days.");
Log.d(TAG, "Initial inventory query finished; enabling main UI.");
}
};