Reputation: 41
I am working on my first android app. I really learned a lot on stack overflow. But I with my current problem I did not find a solution yet.
I tried to implement "in app purchase". I did the following things:
1) In the developer console I uploaded a signed apk in alpha and beta test. I also added a test user to the account and for testing I am using that account. Additionally I added some "In app products(managed)" with the status active.
2) Like described on http://developer.android.com/training/in-app-billing/index.html I downloaded the necessary lib field, copied code from the example project TrivialDrive and followed all the steps which result to the coding:
// called when the app is started
public void setupConnectionToGooglePlay(final Context context) {
this.context = context;
mHelper = new IabHelper(context, base64EncodedPublicKey);
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
if (!result.isSuccess()) {
// Oh no, there was a problem. --> no error message shown to
// the user!
Toast.makeText(context, "No connection to google:" + result, Toast.LENGTH_LONG).show();
} else {
Toast.makeText(context, "connection to google:" + result, Toast.LENGTH_LONG).show();
// If connection is established:
get List of all in App Purchase products
getListOfInAppPurchaseProducts();
}
}
});
}
When executing this part of code I get the result, that the connection was established successfully. Hence the method getListOfInAppPurchaseProducts() is called.
private void getListOfInAppPurchaseProducts() {
IabHelper.QueryInventoryFinishedListener mQueryFinishedListener = new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
if (result.isFailure()) {
// no error message is shown to the user
Toast.makeText(context, "Query not successful", Toast.LENGTH_LONG).show();
} else {
String message = result.getMessage();
boolean isSuccess = result.isSuccess();
// no success message is shown to the user
List<String> skus = inventory.getAllOwnedSkus();
Map<String,SkuDetails> map = inventory.getSKUMap();
int size = map.size();
Toast.makeText(
context,
"Message: " + message + "Query successful. Mapsize:" + size, Toast.LENGTH_LONG).show();
WMGooglePlayConnection.this.inventory = inventory;
}
}
};
ArrayList<String> list = new ArrayList<String>();
list.add("test");
list.add("test2");
mHelper.queryInventoryAsync(true, list, mQueryFinishedListener);
}
Unfortunately the returned inventory does not contain any SKU Details (even the query is successful). I checked the following:
For testing I used a real device (Samsung ACE 2). I copied the apk file directly to the device (not downloaded from google play). Can this be a problem?
Is it somehow possible to get the SKU Details also with the emulator?
Do you have any idea what I can check?
It would be really nice if someone could help me...
Upvotes: 4
Views: 2810
Reputation: 29
I just ran into this as well. Our in app billing stuff broke right around when Google Play Service 4.4 went out. A week or two back I think.
To get your in app billing products to show up now you'll have to publish your Alpha builds but have them only visible to people on your tester list/group.
After one publishes the app then testers can download it from the Google Play Store with a link similar to this.
https://play.google.com/apps/testing/
I hope this helps.
Upvotes: 2