25

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?

Ivan Bartsov
  • 19,664
  • 7
  • 61
  • 59
AndyD273
  • 7,177
  • 12
  • 54
  • 92

9 Answers9

10

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.

Sephy
  • 50,022
  • 30
  • 123
  • 131
  • 1
    Well foo. Whats the point of having an example application to make sure that you are doing it right if you can't actually run it? Can I put something in the market without putting it up for sale? Any way to create a test server? – AndyD273 Aug 18 '10 at 13:14
  • well I don't know , but I suppose that if you want to publish on the market, you need to pay the 25$ fee no? – Sephy Aug 18 '10 at 13:48
  • 4
    Well, I have paid the fee, got all my information inputed, and have everything ready to go on that end, I just don't want to put it up for sale until it's actually ready to sell, with no bugs. As is, I don't have the LVL implemented fully, so I'm pretty sure it will have all kinds of errors. – AndyD273 Aug 18 '10 at 15:12
  • @AndyD273 +2 for describing exactly my situation and articulating my own questions. – an00b Jun 15 '11 at 13:41
  • You can pay the 25 and upload but NOT publish the app and then test the Licensing service but make sure that your package name is correct before the upload. – Robert Massaioli Jan 01 '12 at 07:01
  • Rescinding my comment from above, the version code can be greater. – tjb Sep 26 '12 at 09:34
  • Hey, i had uploaded apk but not published (it's testing app)with same package identifier. how to test app, a marked uploaded build or developement build. – Bipin Vayalu Oct 23 '13 at 15:50
  • I ran into this error today and tested a bit. Here's the current behavior: my published versionCode is 19. I tested versionCode 20, and got NOT_MARKET_MANAGED. I uploaded a draft of versionCode 20, and the licensing then worked properly. So, you can either wait to increment your versionCode, or upload a draft of the new versionCode. No idea why Google thought this behavior was useful, but there it is. – Luke Jan 19 '16 at 08:57
9

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
 * <a href="http://market.android.com/publish/editProfile">Edit Profile</a>
 * 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:

enter image description here

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:

enter image description here

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:

enter image description here

Oh, and you can't really upload that "Market Licensing Example" as is. You must at least change the name of the package:

enter image description here

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?

an00b
  • 11,338
  • 13
  • 64
  • 101
  • 2
    I'm hoping that as Android matures a little it they will add some of this into the SDK so it works without a lot of work. Here is what I followed to finally get the licensing stuff to work correctly: `http://www.droidforums.net/forum/android-app-developers/69899-market-license-easy-implementation-protect-your-apps.html` I may play around with this whole process again in the future when I make another app. Maybe they'll make it work correctly by then. Thanks for testing this out. – AndyD273 Jun 15 '11 at 18:20
  • 2
    Oh, try this: Go into application manager and kill the app, or restart the device, and try again. I found that it was caching the response from google, so if I marked it as licensed, opened the app. went back to the home screen, marked it unlicensed, and opened the app again, it would still show up licensed. Once I killed the app process, it would recheck the license status and return the unlicensed response. – AndyD273 Jun 15 '11 at 18:23
  • @AndyD273 +2 again for the fantastic link and for understanding the plight through which n00bs like me have to go through. In the meanwhile I discovered that testing the "Market Licensing Example" is [impossible](http://stackoverflow.com/questions/6365118/market-licensing-example-always-getting-licensed)! – an00b Jun 15 '11 at 22:56
  • @AndyD273 - The reason why LVL was allowing access to your app even though you selected NON-LICENSED is because you uploaded the apk. As seen at the LVL google page : "Additionally, as noted above, applications that are in draft mode (in other words, applicaitons that have been uploaded but have never been published) will return LICENSED for all users, even if not listed as a test user. Since the application has never been offered for download, it is assumed that any users running it must have obtained it from an authorized channel for testing purposes." – dell116 Jul 28 '11 at 18:24
  • Thanks dell116. Oddly, I was getting the unlicensed message before I officially published it for sale in the store, though maybe they've changed stuff since then? I just had to force the app to recheck the status by making sure it was fully shut down via phone restart or by killing the process. The next time I try to brave publishing something to the Android store I'll pay better attention to the steps I take. I hope they start thinking through the whole license thing, to make it more useable and friendly. – AndyD273 Aug 01 '11 at 19:19
  • @dell116 see here my question http://stackoverflow.com/questions/16169622/android-licensing-application-not-works it always return response code 256 which allow application to run in device inspite of the testaccount checking – Khan Apr 24 '13 at 06:18
  • 1
    After uploading **as draft**, you have to wait a few hours for the APK to be available on the market and test correctly your app. – ol_v_er Apr 25 '13 at 12:25
5

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.

Carl Whalley
  • 3,011
  • 8
  • 33
  • 48
  • 2
    Yeah, that's pretty much what I did, put it in the market but saved instead of published. Got rid of that error at least – AndyD273 Aug 21 '10 at 13:23
3

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.)

Jason Moore
  • 7,169
  • 1
  • 44
  • 45
  • Indeed the versionCode of the app you need to test has to be same as the one in Market. Using a higher version code returns this error. Documentation is wrong! – amit Feb 08 '12 at 01:22
  • sometimes it passes with higher version code too .. i wonder if google has deployed some servers with this bug and others with not. maybe it's an A/B test.. haha. – amit Feb 08 '12 at 01:56
3

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!
fr1550n
  • 1,055
  • 12
  • 23
  • ive followed all your steps but i still cant get this to work. are you trying this with the market licensing example provided by Android? Ive given it a different package name and have followed all your steps, but i still end up getting a "LICENSED" response from the server, even though ive tried different test responses...any suggestions? – Hakan Ozbay Jan 12 '12 at 21:22
2

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.

Ivan Bartsov
  • 19,664
  • 7
  • 61
  • 59
1

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.

tjb
  • 11,480
  • 9
  • 70
  • 91
0

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..

akash kubavat
  • 847
  • 6
  • 17
0

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.

Claudio Bernasconi
  • 158
  • 1
  • 1
  • 13