• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1page.title=Licensing Overview
2parent.title=Application Licensing
3parent.link=index.html
4@jd:body
5
6
7<div id="qv-wrapper">
8<div id="qv">
9
10  <h2>Quickview</h2>
11  <ul>
12    <li>Licensing allows you to verify your app was purchased from Google Play</li>
13    <li>Your app maintains control of how it enforces its licensing status</li>
14    <li>The service is free for all developers who publish on Google Play</li>
15  </ul>
16
17  <h2>In this document</h2>
18  <ol>
19  <li><a href="#Secure">License Responses are Secure</a></li>
20  <li><a href="#LVL">Licensing Verification Library</a></li>
21  <li><a href="#Reqs">Requirements and Limitations</a></li>
22  <li><a href="#CopyProtection">Replacement for Copy Protection</a></li>
23</ol>
24
25</div>
26</div>
27
28
29<p>Google Play Licensing is a network-based service that lets an application query a trusted
30Google Play licensing server to determine whether the application is licensed to the current
31device user. The licensing service is based on the capability of the Google Play licensing server
32to determine whether a given user is licensed to use a given application. Google Play considers a
33user to be licensed if the user is a recorded purchaser of the application.</p>
34
35<p>The request starts when your application makes a request to a service hosted by
36the Google Play client application. The Google Play application then sends a request to
37the licensing server and receives the result. The Google Play application sends
38the result to your application, which can allow or disallow further use of the
39application as needed.</p>
40
41<p class="note"><strong>Note:</strong> If a version of an app is in the alpha or
42beta channel, all users who are authorized to download and install that app are
43considered to be licensed users of the app. For more information, see <a
44href="{@docRoot}distribute/googleplay/developer-console.html#alpha-beta">Alpha
45and Beta Testing</a>.</p>
46
47<div class="figure" style="width:469px">
48<img src="{@docRoot}images/licensing_arch.png" alt=""/>
49<p class="img-caption"><strong>Figure 1.</strong> Your application initiates a
50license check through the License Verification Library and the Google Play
51client, which handles communication with the Google Play server.</p>
52</div>
53
54<p class="note"><strong>Note:</strong> Previously you could test an app by
55uploading an unpublished "draft" version. This functionality is no longer
56supported; instead, you must publish it to the alpha or beta distribution
57channel. For more information, see <a
58href="{@docRoot}google/play/billing/billing_testing.html#draft_apps">Draft Apps
59are No Longer Supported</a>.
60
61<p>To properly identify the user and determine the license status, the licensing server requires
62information about the application and user&mdash;your application and the Google Play client work
63together to assemble the information and the Google Play client passes it to the server. </p>
64
65<p>To help you add licensing to your application, the Android SDK provides a downloadable set of
66library sources that you can include in your application project: the Google Market
67Licensing package. The License Verification Library (LVL) is a library you can add to your
68application that
69handles all of the licensing-related communication with the Google Play licensing service. With
70the LVL added to your application, your application can determine its licensing status for the
71current user by simply calling a method and implementing a callback that receives the status
72response.</p>
73
74<p>Your application does not query the licensing server
75directly, but instead calls the Google Play client over remote IPC to
76initiate a license request. In the license request:</p>
77
78<ul>
79<li>Your application provides: its package name, a nonce that is later used to
80validate any response from the server, and a callback over which the
81response can be returned asynchronously.</li>
82<li>The Google Play client collects the necessary information about the user and the device,
83such as the device's primary Google account username, IMSI, and other
84information. It then sends the license check request to the server on behalf of
85your application.</li>
86<li>The Google Play server evaluates the request using all available information, attempting
87to establish the user's identity to a sufficient level of confidence. The server
88then checks the user identity against purchase records for your application and
89returns a license response, which the Google Play client returns to your
90application over the IPC callback.</li>
91</ul>
92
93<p>You can choose when, and how often, you want your application to check its
94license and you have full control over how it handles the response, verifies the
95signed response data, and enforces access controls.</p>
96
97<p>Notice that during a license check, your application does not manage any
98network connections or use any licensing related APIs in the Android platform.</p>
99
100
101
102
103<h2 id="Secure">License Responses are Secure</h2>
104
105<p>To ensure the integrity of each license query, the server signs the license
106response data using an RSA key pair that is shared exclusively between the Google Play
107server and you.</p>
108
109<p>The licensing service generates a single licensing key pair for each
110application and exposes the public key in your application's
111<strong>Services & APIs</strong> page in the Developer Console. You must copy
112the public key from the Developer Console and embed it in your application
113source code. The server retains the private key internally and uses it to sign
114license responses for the applications you publish with that account.</p>
115
116<p>When your application receives a signed response, it uses the embedded public
117key to verify the data. The use of public key cryptography in the licensing
118service makes it possible for the application to detect responses that have been
119tampered with or that are spoofed.</p>
120
121
122
123
124<h2 id="LVL">Licensing Verification Library</h2>
125
126<p>The Android SDK provides a downloadable package called the Google Market Licensing package,
127which includes the License Verification Library (LVL). The LVL greatly simplifies the process of
128adding licensing to your application and helps ensure a more secure, robust implementation for your
129application. The LVL provides internal classes that handle most of the standard operations of a
130license query, such as contacting the Google Play client to initiate a license request and
131verifying and validating the responses. It also exposes interfaces that let you easily plug in your
132custom code for defining licensing policy and managing access as needed by your application. The key
133LVL interfaces are: </p>
134
135<dl>
136<dt>{@code Policy}</dt>
137  <dd>Your implementation determines whether to allow access to the
138application, based on the license response received from the server and any
139other data available (such as from a backend server associated with your
140application). The implementation can evaluate the various fields of the license
141response and apply other constraints, if needed. The implementation also lets
142you manage the handling of license checks that result in errors, such as network
143errors.</dd>
144
145<dt>{@code LicenseCheckerCallback}</dt>
146  <dd>Your implementation manages access to the
147application, based on the result of the {@code Policy} object's handling of the license
148response. Your implementation can manage access in any way needed, including
149displaying the license result in the UI or directing the user to purchase the
150application (if not currently licensed).</dd>
151</dl>
152
153
154<p>To help you get started with a {@code Policy}, the LVL provides two fully complete
155{@code Policy} implementations that you can use without modification or adapt to your
156needs:</p>
157
158<dl>
159<dt><a href="adding-licensing.html#ServerManagedPolicy">{@code ServerManagedPolicy}</a></dt>
160  <dd>A flexible {@code Policy}
161that uses settings provided by the licensing server to manage response caching
162and access to the application while the device is offline (such as when the
163user is on an airplane). For most applications, the use of
164{@code ServerManagedPolicy} is highly recommended.</dd>
165
166<dt><a href="adding-licensing.html#StrictPolicy">{@code StrictPolicy}</a></dt>
167  <dd>A restrictive {@code Policy} that
168does not cache any response data and allows the application access <em>only</em>
169when the server returns a licensed response.</dd>
170</dl>
171
172<p>The LVL is available as a downloadable package of the Android SDK. The
173package includes both the LVL itself and an example application that shows how
174the library should be integrated with your application and how your application
175should manage response data, UI interaction, and error conditions. </p>
176
177<p>The LVL sources are provided as an Android <em>library project</em>, which
178means that you can maintain a single set of library sources and share them
179across multiple applications. A full test environment is also available through
180the SDK, so you can develop and test the licensing implementation in your
181applications before publishing them, even if you don't have access to a
182physical device.</p>
183
184
185
186
187<h2 id="Reqs">Requirements and Limitations</h2>
188
189<p>Google Play Licensing is designed to let you apply license controls to
190applications that you publish through Google Play. The service is not
191designed to let you control access to applications that are not published
192through Google Play or that are run on devices that do not offer the Google
193Play client. </p>
194
195<p>Here are some points to keep in mind as you implement licensing in your
196application: </p>
197
198<ul>
199<li>An application can use the service only if the Google Play client is
200installed on its host device and the device is running Android 1.5 (API level 3) or higher.</li>
201<li>To complete a license check, the licensing server must be accessible over
202the network. You can implement license caching behaviors to manage access to your application when
203there is no network connectivity. </li>
204<li>The security of your application's licensing controls ultimately relies on
205the design of your implementation itself. The service provides the building
206blocks that let you securely check licensing, but the actual enforcement and
207handling of the license are factors are up to you. By following the best
208practices in the following documents, you can help ensure that your implementation will be
209secure.</li>
210<li>Adding licensing to an application does not affect the way the application
211functions when run on a device that does not offer Google Play.</li>
212<li>You can implement licensing controls for a free app, but only if you're using the service to
213provide <a
214href="{@docRoot}google/play/expansion-files.html">APK expansion files</a>.</li>
215</ul>
216
217
218
219<h2 id="CopyProtection">Replacement for Copy Protection</h2>
220
221<p>Google Play Licensing is a flexible, secure mechanism for controlling
222access to your applications. It effectively replaces the Copy Protection
223mechanism (no longer supported) that was previously offered on Google Play and
224gives you wider distribution potential for your applications. </p>
225
226<p>Licensing lets you move to a license-based model that is enforceable on
227all devices that have access to Google Play. Access is not bound to the
228characteristics of the host device, but to your
229application on Google Play (through the app's public key) and the
230licensing policy that you define. Your application can be installed and
231managed on any device on any storage, including SD card.</p>
232
233<p>Although no license mechanism can completely prevent all unauthorized use,
234the licensing service lets you control access for most types of normal usage,
235across all compatible devices, locked or unlocked.</p>
236
237<p>To begin adding application licensing to your application, continue to <a
238href="{@docRoot}google/play/licensing/setting-up.html">Setting Up for Licensing</a>.</p>
239
240
241
242
243
244
245