Now I managed to sign the apk (using Eclipse Android Tools) and adb install .. to the device for testing.
But this removed the debug function, e.g. "step over" which make problem tracing much more difficult.
Is it possible to debug the inapp billing using Eclipse?
Unfortunately I don't think there is any way to step debug, I have just been using print outputs. This is due to the fact that you have to sign your app with a release key in order for it to communicate properly with the billing service. Very annoying.
When you go through the in app billing documentation, you kinda realize that it can take substantial amount of time to understand this complex piece of technology. Most developers feel the need for a working HelloWorld, and then later play around with the builds.
I have uploaded 2 projects
The android sample project. You can download this project, and immediately run the sample. This will help you quickly debug/trace thru and figure out how the in app billing works.
A cleaned up project to help you integrate your app quickly. This can help like a library. Just integrate make your “purchase requests” on your “checkout” button action.
Mind you : I have not incorporated the security recommendations. Read android in app billing documentation. Until then you are on your own risk.
For 1
Download “http://www.4shared.com/file/f5wH3qke/InAppBilling1.html”
Create a new gmail account for all correspondence (Why, I will explain below)
Pay that 25$ and purchase a “Market Place” account.
Import the project to your eclipse environment
Create a signed application apk, File-Export-Select Your Project-Create OR Use keystore, it should be valid for 25 years from today.
Upload the signed apk to the market place as a “Draft Application”, DO NOT PUBLISH it.
For the uploaded apk, you need to add “In App Products”. You will find this link on the home page for your uploaded apk.
In Security.java dont forget to add your “public key” from your market place account “edit profile” page.
On the “In App Product List”, you need to add the following products one by one
The text below should used as “In app Product id”
sword_001 as Managed
potions_001 as Unmanaged
Title and Description dont matter (for testing purpose). Add what you need here.
Cost add 1$ (minimum)
Click auto fill
Save
Publish the in app project (dont get confused here, you only need to publish the in app product, NOT the APP)
In the test account, add your personal gmail id here. Now, this gmail account needs to be configured as your first gmail account on your phone.
Yes, this WONT work on your emulator
Now the sample app should work.
For 2
Download “http://www.4shared.com/file/h8YnJyf_/InAppBillingIntegration.html”
To integrate, in your calling activity initialize the checkout code
Handler handler = new Handler() ;
CheckoutPurchaseObserver checkout = new CheckoutPurchaseObserver(this, handler);
To send the checkout request for your product
checkout.sendCheckoutRequest(purchaseUri.toString(),null);
Important Note :
This purchaseUri is the “In-app Product ID” of your resource on the “market.android.com/publish-->Create New In-App Product” options. This string should be set as the “in app product” id.
That’s why the “id” is most important. The “In-App Product ID” is how you refer to that particular product.
Also, in Security.java dont forget to add your “public key” from your market place account “edit profile” page.**
Debugging Notes
LogCat will show all errors as InAppBilling tag
This project creates a shared_preferences named “inappbilling” And debug is set to true
The androidmanifest.xml may not be needed since this project does not
have a home screen.
Why do we need to create a new gmail account ?
Simple. The account you purchase your market place account for, cant be used for “testing” your in app billing. Since you cannot purchase products for yourself. And your primary account on your device should be set as a “test account” on the market place account. Chicken-Egg issue here. Hope its clear.
An interesting blog I came by “http://crazyviraj.blogspot.com/2011/06/some-notes-on-implementing-in-app.html“ (not mine).
In my app, I used the test product id, android.test.purchased, which will simulate the actual buying process (ie, will show the in app dialog and you'll be able to purchase and get a response that can be handled by your application). Using that product id, you can run the in app code on the device (unsigned) via eclipse over usb connection. You still might need to work around some things for testing (ie, account for the fact that you are using a testing product id and not your real id), but I found using that product ID did help me quite a bit.
See the testing section of the in app billing guide
Related
I have cloned the project from https://github.com/actions-on-google/appactions-common-biis-kotlin. I made the package name of this project the same as my draft project in Play Console which has a temporary app name 'com.acesoft.actions (unreviewed)'. I can trigger the app actions with App Action Test Tool (AATT). If I set the Invocation Name to "test app" with AATT, it would work on my physical test device if I say "Open active tasks in test app". However, Google Assistant would not open the app when I say "Open active tasks in todo". Todo is the display name for the app. According to the documentation, the default invocation name is the display name of the app. The command "Open active tasks in todo" would result in a search in the web. What did I do wrong? How do I invoke the app actions without AATT?
I have also tried typing the following in Google Assistant:
"open active tasks in todo"
"open active tasks in actions" ("actions" is the last part of the temporary name)
All these commands would result in web searches instead of opening the app!
Can anyone help?
If your app is not published on the Play store, it definitely will not work. Google Assistant only formally recognizes apps that have been uploaded and have passed review. It works in the test tool because that tool establishes a temporary "preview" of how things will work if it were fully published.
Still, in some cases, Google Assistant is unable to match the name of the app as spoken to the name of the app as installed on the device. This situation is not possible to resolve on your own. What you will need to do is contact Google Assistant support and explain what you are trying to do. They might be able to make a change manually to the backend to enable this.
You can see someone else having a similar problem in this public bug. However, please do not file a new bug, and do not fill out the form unless your app is uploaded to Play. If your app is uploaded to Play, follow the instructions given in the last comment on that issue:
If your app is shipping on the Play store, then you can get support for this using this support form - you should choose "App Actions review" for now, and point out that you would like a manual mapping for your app. Don't worry about the actions console project ID - that is for another project.
For me it was enough to put my app into "internal testing" in the Play Console and then install the app on device through the test link that is provided by the Play Console. I could use Google Assistant and use the app name for invocation.
This might sound like a stupid question but I can't grasp if I'm doing this correctly.
I created an app in the developer console using the "Game Services"-tab. Meaning I didn't actually "create" an app as far as I understand. In the "All applications"-tab I have ZERO apps because I haven't created one there yet. But if I check the "Linked apps"-tab, I already have an app there with a bundle-id xxx.yyy.zz (not the real id). If I now create an app in the "All applications"-tab with the same bundle-id (xxx.yyy.zz), will it automatically be linked?
To properly link an app to the Game Service you will need to also specify the fingerprint of the signing certificate you use for your app and the package must match.
Check out Step 2 in this guide for the exact steps needed.
Recently I've been trying to get my Adobe Air AS3 Android game to work with Google Play Game Services.
I'm using the Milkman Native Extension and Flashdevelop.
I made my own sign in button, and when I press it the standard "Sign in with your account" window with all my accounts appears. The first time I sign in with an account it even gives me the standard options to share my game status to my Google+ circles. Then, when I do try to log in, the service shows the standard spinning progress wheel, then disappears, the "Signed in as PLAYER" box doesn't show up, and I'm not logged in. The ANE tells me that it's an unknown_error_code.
Things I've noticed:
It doesn't let me see a list of achievements or leaderboards either.
After the first time I log in it just tries
to log me in again indefinitely.
The "Apps using google+ data" shows it as a "3rd party app" and not the actual title of the app. EDIT: It now displays it as the correct app for some reason. Still doesn't sign me in though...
I'm pretty sure this isn't a coding problem.
Things I've tried:
Matching the SHA1 key with the SHA1 key from my p12 key.
Logging into different accounts.
Making my accounts tester accounts.
Using non tester accounts.
Making new Game Service pages
Making new application pages
Changing my app I.D. (com.blank.mygame)
Clearing the "Apps using google+ data"
Making the Version Number of the game higher than the most recent test account
Making new Google+ accounts
Syncing my app to the services page.
Desyncing my app from the services page.
Making new OAuth 2.0 client I.D.s.
Publishing the game services.
Any suggestions?
Now I can answer my question officially:
I fixed it.
Apparently if you go to the API console and change the Oauth from there the game services doesn't detect it. I originally put in the wrong SHA1 and fixed it through the API and not the google services developer console.
http://www.youtube.com/watch?v=nkJS_W-VC9I (it's problem #6 which is really n)
I was having the same problem, and I solved it by changing the App/Package ID at the Google Developer Console from:
com.developer.appname
to:
air.com.developer.appname
I had simliar issue - the app was asking for permition, but it triggered onSignInFailed event.
Tried several things, the problem was with runtime enviroment - everything works correctly when I include it to application. (I was using separate AIR runtime enviroment to decrease the time of publishing the app)
I'm trying to use Google Play Game Services in my practice Android app.
I got the sign in buttons UI as explained in the developer guide. When I hit the sign in for the first time, it guides me through sign in process. Right after it's about to finish the process, it gives me a dialog with "Unknown error". After the first time, it always gives me this dialog after displaying the loading animation for a bit.
I imported BaseGameUtils and google-play-services_lib. I attached reference from BaseGameUtils to the google-play-services_lib. Then attached reference of these 2 to my game project.
I exported the project to get the SHA1 to put in the developer console. Then I have my 12 digit app id to place on the values/ids.xml (got the meta tag under application).
Tried cleaning the project, redoing the SHA1/keystore process and no luck. My email is under the testing access.
I read and tried the solutions provided on this question, but it was not my case.
Google Play Game Services - unable to sign in
Anybody experiencing the same or does anyone have a solution I should try?
Try going to your Google+ settings on your device and purging the access that you had granted the app. Afterwards, MANUALLY set up Google+ for your test account, either through a PC/Mac web browser or through your device, then try re-linking the app. This worked for me.
Exact steps for Samsung Galaxy S3:
Settings -> Google -> Google+ -> Apps with Google+ Sign-In -> tap the app and at the bottom, tap Disconnect App.
For what it’s worth, I also tapped the option to “Delete all activity for this app” as well when I deleted it.
Your ids.xml has to look like:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_id">XXXXXXXXX</string>
</resources>
And, in your manifest, you have to add:
<meta-data android:name="com.google.android.gms.games.APP_ID"
android:value="#string/app_id" />
Good luck!
I recommend utilising the debug log trace in the GameHelper class to get a clearer picture of the error. You can simply make a call in your onCreate to do this...
enableDebugLog(true, "fred"); where "fred" is the tag you want to show on logcat
It is most likely that you will then see an error like "OnConnection Failed result 4... SIGN IN REQUIRED. If you then search SO for that message you should be able to make some progress.
Another possibility:
I managed to get my own leaderboard into production last night. The error you are describing is one that I (and judging by other comments that I have seen in error reports on SO ) and other people have also encountered. I found that I was unable to use the google account that I user in the developer console to sign on, even though it is explicitly listed as a testing account for the game. I tried shutting down the emulator, deleting and redefining the game in the developer console etc. but I have never been able to get it to work.
I used a different account and I was able to sign on. I do not know what the problem is with my developer console account - I also use it in Google Plus without problems. Incidentally, I am still unable to use my developer account on the production app with a real device.
My advice is to use a separate account for testing. Good luck !
If you are using your production keystore to get the fingerprint, you need to export and use a release build. Otherwise, use the debug keystore to get the fingerprint.
According to https://developers.google.com/games/services/console/enabling#b_create_a_client_id - if using eclipse, the debug keystore is located at
~/.android/debug.keystore
One more thing, for me, I couldn't sign in using my publisher account but one of my other accounts worked ok. Maybe worth a try.
One additional thing that can be tried is to send (as attachment) the exported and signed yourapp.apk to the tester's account's email, and then install the app through email (by clicking on the attachment), and not through the usb.
It seems to me the problem here is not with play services, but with google+, as it sometimes takes several days for the changes (such as deleting some info) to take effect. If nothing works, create a new gmail account, and try again (that's what "worked" for me eventually :)).
Edit: old accounts that didn't work initially started working after 4 - 5 days. Maybe it just takes Google some time to synchronize everything.
Working on trying out the market licensing service, and I'm running into a few problems with the sample application.
When I first ran the sample, I got an error saying that the application was not licensed. I linked my account to the simulator in order to get it to get the test response, and now I get an error saying "Application error: NOT_MARKET_MANAGED"
Does this mean that I have to upload the app to the market in order to test to see if it works?
Yes your app has to be on the market and if it already is, you have to have a version code number which is greater or equal than the one already published.
There may be another way. The comments on the sample's MainActivity read:
* The first thing you need to do is get your hands on your public key.
* Update the BASE64_PUBLIC_KEY constant below with your encoded public key,
* which you can find on the
* Edit Profile
* page of the Market publisher site.
* <p>
* Log in with the same account on your Cupcake (1.5) or higher phone or
* your FroYo (2.2) emulator with the Google add-ons installed. Change the
* test response on the Edit Profile page, press Save, and see how this
* application responds when you check your license.
And when you log into http://market.android.com/publish/editProfile you will see an option for changing the License Test Response:
Textually saying:
This License Test Response will be
sent to devices using #gmail.com
or the Test Accounts listed above for
applications you have uploaded to
Market. Additionally, this account
(but not the Test Accounts) will
receive this response for applications
that have not yet been uploaded to
Market.
If you click that selection list, you will see different options:
I guess all you have to do, for that initial sample LVL tutorial program, is change the response from Respond normally to LICENSED or any other setting you want to test.
UPDATE: It turns out that the above measure is insufficient. I still get the NOT_MARKET_MANAGED error. I guess that "Market Licensing Example" must be uploaded as previous answers suggested. Note, however, that it cannot be the debug version:
Oh, and you can't really upload that "Market Licensing Example" as is. You must at least change the name of the package:
I can see how Google's sample/example system could be improved to become more developer-friendly...
Weird. After uploading the application (just uploading and saving draft, not filling any other required fields), the "Market Licensing Example" stops issuing the NOT_MARKET_MANAGED error, despite the fact that clearly selected NOT_LICENSED. Instead it responds with the message Allow the user access. I also tried setting (for test & learning purposes) it to ERROR_SERVER_FAILURE but I get the same Allow the user access message.
Why?
You'd have thought "Saved Draft" would be just what this is for. Otherwise, you're selling an app which by definition cannot have been fully tested live.
Upload your app (.apk) to the market. The default state will be "Saved Draft", so it will not be be visible to the public, but you can still test the Licensing.
One other potential problem:
Make sure that the version you are testing/running has the same android:versionCode in the AndroidManifest.xml as the draft version in the market. If the versions differ, you will receive a NOT_MARKET_MANAGED error. (Apparently the RSA keypair used for license
checks is on a per-app/per-version basis.)
After a bit of a struggle I got this working. You can't use the LVL sample as is.
Here's what I did:
modify the project's package to something else (I used: lvl.test)
set MainActivity's BASE64_PUBLIC_KEY to the one in your Developer Console profile.
export the signed app
go to Developer Console and upload the app (create dummy images and give it a dummy name and description etc. just so that it saves and is listed as 'Unpublished')
install the exported app (from your filesystem) to your test device (i.e. adb install bin/path/to/your.apk)
on your device, open Android Market go to: Settings>Accounts> and select the one that corresponds to your Developer Console account
you can now select a static License Test Response in your Developer Console Profile and save it. When you run the LVL sample on your device the response will correspond to the one you picked!
From my experience, the app has to be published before LVL starts working, incl. static response testing. For me ERROR_NOT_MARKET_MANAGED went away only after publishing although the docs say you can Debug and test an application's licensing implementation, prior to
publishing the application.
Cool part is you can publish while only having alpha/beta builds -- the app won't really go live, only testing accounts will be able to use it.
When you're preparing for initial release, it may seem unnatural to hit Publish before you're completely sure everything is in working order (and the fact that you have to put in the description and screenshots before you can do that is even more alarming -- you'd think those are final touches) -- but you should, just make sure you've made a sane choice about the package name and whether the app is paid or free -- those things can't be changed after publishing. Publishing alone does not make the app public; unless you have a Production build don't worry about accidentally making an untested version go live.
This is related so it might help somebody:
I was testing on an Asus transformer and had to delete all non-developer accounts to get license testing to work (including my yahoo account). Once the other accounts were deleted all of the steps worked without a problem.
In my case I was getting because of Version code difference as..
Already published apk's version code = 2
and after some testing release new apk's I had set version code to 5
which was causing this error as version difference should be exact 1 with currently published apk..
same was applied with version name too..
If you already tried all the suggestions above try this:
I had the same response for a while and I could not figure out why this was the case. I read the entire documentation on App Licensing and still receiving the same annoying NOT_MARKET_MANAGED response code.
I was finally abe to resolve the problem by changing my applicationId in the AndroidManifest.xml file. I rewrote an app from scratch starting with a blank new project. The problem was that I did not use the exact correct applicationId. The problem was that the original application on the Google Play Store used a letter in upper case while I wrote all letters in lower case in the newly created project.
Since I corrected the applicationId to match 100% (including casing) I get the expected behavior of the licensing service.