Home | History | Annotate | Download | only in licensing
      1 page.title=Setting Up for Licensing
      2 parent.title=Application Licensing
      3 parent.link=index.html
      4 @jd:body
      5 
      6 
      7 <div id="qv-wrapper">
      8 <div id="qv">
      9   
     10   <h2>In this document</h2>
     11   <ol>
     12   <li><a href="#account">Setting Up a Publisher Account</a></li>
     13   <li><a href="#dev-setup">Setting Up the Development Environment</a>
     14     <ol>
     15       <li><a href="#runtime-setup">Setting up the runtime environment</a></li>
     16       <li><a href="#download-lvl">Downloading the LVL</a></li>
     17       <li><a href="#lvl-setup">Setting Up the Licensing Verification Library</a></li>
     18       <li><a href="#add-library">Including the LVL library project sources in your
     19 application</a></li>
     20     </ol>
     21   </li>
     22   <li><a href="#test-env">Setting Up the Testing Environment</a>
     23     <ol>
     24       <li><a href="#test-response">Setting test responses for license checks</a></li>
     25       <li><a href="#test-acct-setup">Setting up test accounts</a></li>
     26       <li><a href="#acct-signin">Signing in to an authorized account in the runtime
     27 environment</a></li>
     28     </ol>
     29   </li>
     30 </ol>
     31 </div>
     32 </div>
     33 
     34 <p>Before you start adding license verification to your application, you need to set up your Google
     35 Play publishing account, your development environment, and test accounts required to verify
     36 your implementation.</p>
     37 
     38 
     39 <h2 id="account">Setting Up a Publisher Account</h2>
     40 
     41 <p>If you don't already have a publisher account for Google Play, you need to register for one
     42 using your Google account and agree to the terms of service on the Google Play publisher site:</p>
     43 
     44 <p style="margin-left:2em;"><a
     45 href="http://play.google.com/apps/publish">http://play.google.com/apps/publish</a>
     46 </p>
     47 
     48 <p>For more information, see <a
     49 href="{@docRoot}distribute/googleplay/publish/register.html">Get Started with Publishing</a>.</p>
     50 
     51 <p>If you already have a publisher account on Google Play, use your existing
     52 account to set up licensing.</p>
     53 
     54 <p>Using your publisher account on Google Play, you can:</p>
     55 
     56 <ul>
     57 <li>Obtain a public key for licensing</li>
     58 <li>Debug and test an application's licensing implementation, prior to
     59 publishing the application</li>
     60 <li>Publish the applications to which you have added licensing support</li>
     61 </ul>
     62 
     63 <h4>Administrative settings for licensing</h4>
     64 
     65 <p>You can manage several
     66 administrative controls for Google Play licensing on the publisher site. The controls are available
     67 in the Edit Profile page, in the "Licensing" panel, shown in figure 1. The controls
     68 let you: </p>
     69 
     70 <ul>
     71 <li>Set up multiple "test accounts," identified by email address. The licensing
     72 server allows users signed in to test accounts on a device or emulator to send
     73 license checks and receive static test responses.</li>
     74 <li>Obtain the account's public key for licensing. When you are implementing
     75 licensing in an application, you must copy the public key string into the
     76 application.</li>
     77 <li>Configure static test responses that the server sends, when it receives a
     78 license check for an application uploaded to the publisher account, from a user
     79 signed in to the publisher account or a test account.</li>
     80 </ul>
     81 
     82 
     83 <img src="{@docRoot}images/licensing_public_key.png" alt=""/>
     84 <p class="img-caption"><strong>Figure 1.</strong> The Licensing
     85 panel of your account's Edit Profile page lets you manage administrative
     86 settings for licensing.</p>
     87 
     88 <p>For more information about how to work with test accounts and static test
     89 responses, see <a href="#test-env">Setting Up a Testing Environment</a>, below.
     90 
     91 
     92 
     93 <h2 id="dev-setup">Setting Up the Development Environment</h2>
     94 
     95 <p>Setting up your environment for licensing involves these tasks:</p>
     96 
     97 <ol>
     98 <li><a href="#runtime-setup">Setting up the runtime environment</a> for development</li>
     99 <li><a href="#download-lvl">Downloading the LVL</a> into your SDK </li>
    100 <li><a href="#lvl-setup">Setting up the Licensing Verification Library</a></li>
    101 <li><a href="#add-library">Including the LVL library project in your application</a></li>
    102 </ol>
    103 
    104 <p>The sections below describe these tasks. When you are done with setup,
    105 you can begin <a href="{@docRoot}guide/google/play/licensing/adding-licensing.html">Adding
    106 Licensing to Your App</a>.</p>
    107 
    108 <p>To get started, you need to set up a proper runtime environment on which
    109 you can run, debug, and test your application's implementation of license
    110 checking and enforcement. </p>
    111 
    112 
    113 <h3 id="runtime-setup">Setting up the runtime environment</h3>
    114 
    115 <p>As described earlier, applications check licensing status not by contacting
    116 the licensing server directly, but by binding to a service provided by the
    117 Google Play application and initiating a license check request. The Google
    118 Play service then handles the direct communication with the licensing server
    119 and finally routes the response back to your application. To debug and test
    120 licensing in your application, you need to set up a runtime environment that
    121 includes the necessary Google Play service, so that your application is able
    122 to send license check requests to the licensing server. </p>
    123 
    124 <p>There are two types of runtime environment that you can use: </p>
    125 
    126 <ul>
    127 <li>An Android-powered device that includes the Google Play application, or</li>
    128 <li>An Android emulator running the Google APIs Add-on, API level 8 (release 2)
    129 or higher</li>
    130 </ul>
    131 
    132 <h4 id="runtime-device">Running on a device</h4>
    133 
    134 <p>To use an Android-powered device for
    135 debugging and testing licensing, the device must:</p>
    136 
    137 <ul>
    138 <li>Run a compatible version of Android 1.5 or later (API level
    139 3 or higher) platform, <em>and</em> </li>
    140 <li>Run a system image on which the Google Play client application
    141 is preinstalled. </li>
    142 </ul>
    143 
    144 <p>If Google Play is not preinstalled in the system image, your application won't
    145 be able to communicate with the Google Play licensing server. </p>
    146 
    147 <p>For general information about how to set up a device for use in developing
    148 Android applications, see <a
    149 href="{@docRoot}tools/device.html">Using Hardware Devices</a>.</p>
    150 
    151 <h4 id="runtime-emulator">Running on an Android emulator</h4>
    152 
    153 <p>If you don't have a device available, you can use an Android emulator for debugging and testing
    154 licensing.</p>
    155 
    156 <p>Because the Android platforms provided in the Android SDK <em>do
    157 not</em> include Google Play, you need to download the Google APIs Add-On
    158 platform, API level 8 (or higher), from the SDK repository. After downloading
    159 the add-on, you need to create an AVD configuration that uses that system image.
    160 </p>
    161 
    162 <p>The Google APIs Add-On does not include the full Google Play client.
    163 However, it does provide: </p>
    164 
    165 <ul>
    166 <li>An Google Play background service that implements the
    167 <code>ILicensingService</code> remote interface, so that your application can
    168 send license checks over the network to the licensing server. </li>
    169 <li>A set of underlying account services that let you add an a Google account on
    170 the AVD and sign in using your publisher account or test account credentials.
    171 <p>Signing in using your publisher or test account enables you to debug and test
    172 your application without having publish it. For more information see <a
    173 href="#acct-signin">Signing in to an authorized account</a>, below.</p></li>
    174 </ul>
    175 
    176 <p>Several versions of the Google APIs add-on are available through the SDK Manager, but only
    177 the version for Android 2.2 and higher includes the necessary Google
    178 Play services.</p>
    179 
    180 <p>To set up an emulator for adding licensing to an application, follow
    181 these steps: </p>
    182 
    183 <ol>
    184   <li>Launch the Android SDK Manager (available under the Eclipse <strong>Window</strong>
    185 menu or by executing {@code &lt;sdk>/tools/android sdk}).</li>
    186   <li>Select and download <strong>Google APIs</strong> for the Android version you'd like to target
    187 (must be Android 2.2 or higher).</li>
    188   <li>When the download is complete, open the AVD Manager (available under the Eclipse
    189 <strong>Window</strong>
    190 menu or by executing {@code &lt;sdk>/tools/android avd}).</li>
    191   <li>Click
    192 <strong>New</strong> and set the configuration details for the new AVD. </li>
    193   <li>In the dialog that appears, assign a descriptive name to the AVD and then
    194 use the Target menu to choose the <strong>Google APIs</strong> as
    195 the system image to run on the new AVD. Set the other configuration details as
    196 needed and then click <strong>Create AVD</strong> to finish. The SDK tools
    197 create the new AVD configuration, which then appears in the list of available
    198 Android Virtual Devices.</li>
    199 </ol>
    200 
    201 <p>If you are not familiar with AVDs or how to use them, see <a
    202 href="{@docRoot}tools/devices/index.html">Managing Virtual Devices</a>.</p>
    203 
    204 <h4 id="project-update">Updating your project configuration</h4>
    205 
    206 <p>After you set up a runtime environment that meets the requirements described
    207 above &mdash; either on an actual device or on an emulator &mdash; make sure to
    208 update your application project or build scripts as needed, so that your compiled
    209 <code>.apk</code> files that use licensing are deployed into that environment.
    210 In particular, if you are developing in Eclipse, make sure that you set up a
    211 Run/Debug Configuration that targets the appropriate device or AVD. </p>
    212 
    213 <p>You do not need to make any changes to your application's
    214 build configuration, provided that the project is already configured to compile
    215 against a standard Android 1.5 (API level 3) or higher library. For example:
    216 
    217 <ul>
    218 <li>If you have an existing application that is compiled against
    219 the Android 1.5 library, you do not need to make any changes to your
    220 build configuration to support licensing. The build target meets the minimum
    221 requirements for licensing, so you would continue building
    222 against the same version of the Android platform.</li>
    223 
    224 <li>Similarly, if you are building against Android 1.5 (API level 3) but
    225 are using an emulator running the Google APIs Add-On API 8 as the application's
    226 runtime environment, there is no need to change your application's build
    227 configuration. </li>
    228 </ul>
    229 
    230 <p>In general, adding licensing to an application should have no impact
    231 whatsoever on the application's build configuration.</p>
    232 
    233 
    234 <h3 id="download-lvl">Downloading the LVL</h3>
    235 
    236 <p>The License Verification Library (LVL) is a collection of helper classes that
    237 greatly simplify the work that you need to do to add licensing to your
    238 application. In all cases, we recommend that you download the LVL and use it as
    239 the basis for the licensing implementation in your application.</p>
    240 
    241 <p>The LVL is available as a downloadable package of the Android SDK. The
    242 package includes: </p>
    243 
    244 <ul>
    245 <li>The LVL sources, stored inside an Android library project. </li>
    246 <li>An example application called "sample" that depends on the LVL library
    247 project. The example illustrates how an application uses the library helper
    248 classes to check and enforce licensing.</li>
    249 </ul>
    250 
    251 <p>To download the LVL package into your development environment, use the
    252 Android SDK Manager. Launch the Android SDK Manager and then
    253 select the <strong>Google Market Licensing</strong> package, as shown in figure 2.
    254 Accept the terms and click <strong>Install Selected</strong> to begin the download. </p>
    255 
    256 <img src="{@docRoot}images/licensing_package.png" alt=""/>
    257 <p class="img-caption"><strong>Figure 2.</strong> The Licensing package contains the LVL and
    258 the LVL sample application.</p>
    259 
    260 <p>When the download is complete, the Android SDK Manager installs both
    261 the LVL library project and the example application into these directories: </p>
    262 
    263 <p style="margin-left:2em"><code>&lt;<em>sdk</em>&gt;/extras/google/market_licensing/library/</code>
    264 &nbsp;&nbsp;(the LVL library project)<br />
    265 <code>&lt;<em>sdk</em>&gt;/extras/google/market_licensing/sample/</code>&nbsp;&nbsp;(the example
    266 application)</p>
    267 
    268 <p>If you aren't familiar with how to download packess into your SDK, see the
    269 <a href="{@docRoot}sdk/exploring.html">Exploring the SDK</a>
    270 document. </p>
    271 
    272 
    273 <h3 id="lvl-setup">Setting Up the Licensing Verification Library</h3>
    274 
    275 <p>After downloading the LVL to your computer, you need to set it up in your
    276 development environment, either as an Android library project or by
    277 copying (or importing) the library sources directly into your existing
    278 application package. In general, using the LVL as a library project is recommended,
    279 since it lets you reuse your licensing code across multiple applications and
    280 maintain it more easily over time. Note that the LVL is not designed to be
    281 compiled separately and added to an application as a static .jar file. </p>
    282 
    283 <h4>Moving the library sources to a new location</h4>
    284 
    285 <p>Because you will be customizing the LVL sources to some extent, you should
    286 make sure to <em>move or copy</em> the library sources (the entire
    287 directory at <code>&lt;<em>sdk</em>&gt;/market_licensing/library/</code>)
    288 to a working directory outside of the SDK. You should then use the relocated
    289 sources as your working set. If you are using a source-code management
    290 system, add and track the sources that are in the working location rather
    291 than those in default location in the SDK. </p>
    292 
    293 <p>Moving the library sources is important is because, when you later update the
    294 Licensing package, the SDK installs the new files to the same location as
    295 the older files. Moving your working library files to a safe location ensures
    296 that your work won't be inadvertently overwritten should you download a new
    297 version of the LVL.</p>
    298 
    299 <h4>Creating the LVL as a library project</h4>
    300 
    301 <div class="sidebox-wrapper">
    302 <div class="sidebox">
    303 <h2>Working with library projects</h2>
    304 
    305 <p>The LVL is provided as an Android library project, which means that you can
    306 share its code and resources across multiple applications. </p>
    307 
    308 <p style="margin-top:.5em;">If you aren't familiar with library projects or how
    309 to use them, see <a href="{@docRoot}tools/projects/index.html#LibraryProjects">
    310 Managing Projects</a>.
    311 </p>
    312 </div>
    313 </div>
    314 
    315 <p>The recommended way of using the LVL is setting it up as a new Android
    316 <em>library project</em>. A library project is a type of development project
    317 that holds shared Android source code and resources. Other Android application
    318 projects can reference the library project and, at build time, include its
    319 compiled sources in their <code>.apk</code> files. In the context of licensing,
    320 this means that you can do most of your licensing development once, in a library
    321 project, then include the library sources in your various application projects.
    322 In this way, you can easily maintain a uniform implementation of licensing
    323 across all of your projects and maintain it centrally. </p>
    324 
    325 <p>The LVL is provided as a configured library project &mdash; once you have
    326 downloaded it, you can start using it right away. </p>
    327 
    328 <p>If you are working in Eclipse with ADT, you need to add the LVL to your
    329 workspace as a new development project, in the same way as you would a new
    330 application project. </p>
    331 
    332 <ol>
    333 <li>Use the New Project Wizard to create a new
    334 project from existing sources. Select the LVL's <code>library</code> directory
    335 (the directory containing the library's AndroidManifest.xml file) as the project
    336 root.</li>
    337 <li>When you are creating the library project, you can select any application
    338 name, package, and set other fields as needed. </li>
    339 <li>For the library's build target, select Android 1.5 (API level 3) or higher.</li>
    340 </ol>
    341 
    342 <p> When created, the project is
    343 predefined as a library project in its <code>project.properties</code> file, so
    344 no further configuration is needed. </p>
    345 
    346 <p>For more information about how to create an application project or work with
    347 library projects in Eclipse, see <a
    348 href="{@docRoot}tools/projects/projects-eclipse.html">Managing Projects from
    349 Eclipse with ADT</a>.</p>
    350 
    351 
    352 <h4>Copying the LVL sources to your application</h4>
    353 
    354 <p>As an alternative to adding the LVL as a library project, you can copy the
    355 library sources directly into your application. To do so, copy (or import) the
    356 LVL's <code>library/src/com</code> directory into your application's
    357 <code>src/</code> directory.</p>
    358 
    359 <p>If you add the LVL sources directly to your application, you can skip the
    360 next section and start working with the library, as described in <a
    361 href="{@docRoot}guide/google/play/licensing/adding-licensing.html">Adding
    362 Licensing to Your App</a>.</p>
    363 
    364 
    365 <h3 id="add-library">Including the LVL library project sources in your
    366 application</h3>
    367 
    368 <p>If you want to use the LVL sources as a library project, you need to add a
    369 reference to the LVL library project in your application project properties. This tells
    370 build tools to include the LVL library project sources in your application at
    371 compile time. The process for adding a reference to a library project depends
    372 on your development environment, as described below.</p>
    373 
    374 <p> If you are developing in Eclipse with ADT, you should already have added the
    375 library project to your workspace, as described in the previous section. If you
    376 haven't done that already, do it now before continuing. </p>
    377 
    378 <p>Next, open the application's project properties window, as shown below.
    379 Select the "Android" properties group and click <strong>Add</strong>, then
    380 choose the LVL library project (com_android_vending_licensing) and click
    381 <strong>OK</strong>. For more information, see
    382 <a href="{@docRoot}tools/projects/projects-eclipse.html#SettingUpLibraryProject">
    383 Managing Projects from Eclipse with ADT</a></p>.
    384 
    385 
    386 <img src="{@docRoot}images/licensing_add_library.png" alt=""/>
    387 <p class="img-caption"><strong>Figure 3.</strong> If you are
    388 working in Eclipse with ADT, you can add the LVL library project to your
    389 application from the application's project properties.</p>
    390 
    391 
    392 <p>If you are developing using the SDK command-line tools, navigate to the
    393 directory containing your application project and open the
    394 <code>project.properties</code> file. Add a line to the file that specifies the
    395 <code>android.library.reference.&lt;n&gt;</code> key and the path to the
    396 library. For example: </p>
    397 
    398 <pre>android.library.reference.1=path/to/library_project</pre>
    399 
    400 <p>Alternatively, you can use this command to update the project
    401 properties, including the reference to the library project:</p>
    402 
    403 <pre class="no-pretty-print" style="color:black">android update lib-project
    404 --target <em>&lt;target_ID&gt;</em> \
    405 --path <em>path/to/my/app_project</em> \
    406 --library <em>path/to/my/library_project</em>
    407 </pre>
    408 
    409 <p>For more information about working with library projects,
    410 see <a href="{@docRoot}tools/projects/projects-cmdline.html#SettingUpLibraryProject">
    411 Setting up a Library Project</a>.</p>
    412 
    413 
    414 
    415 
    416 
    417 
    418 
    419 
    420 
    421 
    422 
    423 
    424 
    425 
    426 
    427 
    428 
    429 
    430 
    431 
    432 
    433 <h2 id="test-env">Setting Up the Testing Environment</h2>
    434 
    435 <p>The Google Play publisher site provides configuration tools that let you
    436 and others test licensing on your application before it is published. As you are
    437 implementing licensing, you can make use of the publisher site tools to test
    438 your application's Policy and handling of different licensing responses and
    439 error conditions.</p>
    440 
    441 <p>The main components of the test environment for licensing include: </p>
    442 
    443 <ul>
    444 <li>A "Test response" configuration in your publisher account that lets you
    445 set the static licensing response returned, when the server processes a
    446 license check for an application uploaded to the publisher account, from a user
    447 signed in to the publisher account or a test account.</li>
    448 <li>An optional set of test accounts that will receive the static test
    449 response when they check the license of an application that you have uploaded
    450 (regardless whether the application is published or not).</li>
    451 <li>A runtime environment for the application that includes the Google Play
    452 application or Google APIs Add-On, on which the user is signed in to the
    453 publisher account or one of the test accounts.</li>
    454 </ul>
    455 
    456 <p>Setting up the test environment properly involves:</p>
    457 
    458 <ol>
    459 <li><a href="#test-response">Setting static test responses</a> that are returned by the licensing server.</li>
    460 <li><a href="#test-acct-setup">Setting up test accounts</a> as needed.</li>
    461 <li><a href="#acct-signin">Signing in</a> properly to an emulator or device, before initiating a license check test.</li>
    462 </ol>
    463 
    464 <p>The sections below provide more information.</p>
    465 
    466 
    467 <h3 id="test-response">Setting test responses for license checks</h3>
    468 
    469 <p>Google Play provides a configuration setting in your publisher account
    470 that lets you override the normal processing of a license check and return a
    471 specified static response code. The setting is for testing only and applies
    472 <em>only</em> to license checks for applications that you have uploaded, made by
    473 any user signed in to an emulator or device using the credentials of the
    474 publisher account or a registered test account. For other users, the server
    475 always processes license checks according to normal rules.  </p>
    476 
    477 <p>To set a test response for your account, sign in to your publisher account
    478 and click "Edit Profile". In the Edit Profile page, locate the Test Response
    479 menu in the Licensing panel, shown below. You can select from the full set of
    480 valid server response codes to control the response or condition you want to
    481 test in your application.</p>
    482 
    483 <p>In general, you should make sure to test your application's licensing
    484 implementation with every response code available in the Test Response menu.
    485 For a description of the codes, see <a
    486 href="{@docRoot}guide/google/play/licensing/licensing-reference.html#server-response-codes">Server
    487 Response Codes</a> in the <a
    488 href="{@docRoot}guide/google/play/licensing/licensing-reference.html">Licensing Reference</a>.</p>
    489 
    490 <img src="{@docRoot}images/licensing_test_response.png" alt=""/>
    491 <p class="img-caption"><strong>Figure 4.</strong> The Licensing
    492 panel of your account's Edit Profile page, showing the Test Accounts field and the
    493 Test Response menu.</p>
    494 
    495 <p>Note that the test response that you configure applies account-wide &mdash;
    496 that is, it applies not to a single application, but to <em>all</em>
    497 applications associated with the publisher account. If you are testing multiple
    498 applications at once, changing the test response will affect all of those
    499 applications on their next license check (if the user is signed in to
    500 the emulator or device using the publisher account or a test account).</p>
    501 
    502 <p>Before you can successfully receive a test response for a license check,
    503 you must sign in to the device or emulator on which the application
    504 is installed, and from which it is querying the server. Specifically, you must
    505 sign using either your publisher account or one of the test accounts that you
    506 have set up. For more information about test accounts, see the next section.</p>
    507 
    508 <p>See <a
    509 href="{@docRoot}guide/google/play/licensing/licensing-reference.html#server-response-codes">Server
    510 Response Codes</a> for a list of
    511 test responses available and their meanings. </p>
    512 
    513 
    514 <h3 id="test-acct-setup">Setting up test accounts</h3>
    515 
    516 <p>In some cases, you might want to let multiple teams of developers test
    517 licensing on applications that will ultimately be published through your
    518 publisher account, but without giving them access to your publisher account's
    519 sign-in credentials. To meet that need, the Google Play publisher site lets
    520 you set up one or more optional <em>test accounts</em> &mdash; accounts that are
    521 authorized to query the licensing server and receive static test responses from
    522 your publisher account.</p>
    523 
    524 <p>Test accounts are standard Google accounts that you register on your
    525 publisher account, such that they will receive the test response for
    526 applications that you have uploaded. Developers can then sign in to their
    527 devices or emulators using the test account credentials and initiate license
    528 checks from installed applications. When the licensing server receives a license
    529 check from a user of a test account, it returns the static test response
    530 configured for the publisher account.  </p>
    531 
    532 <p>Necessarily, there are limitations on the access and permissions given to
    533 users signed in through test accounts, including:</p>
    534 
    535 <ul>
    536 <li>Test account users can query the licensing server only for applications that
    537 are already uploaded to the publisher account. </li>
    538 <li>Test account users do not have permission to upload applications to your
    539 publisher account.</li>
    540 <li>Test account users do not have permission to set the publisher account's
    541 static test response.</li>
    542 </ul>
    543 
    544 <p>The table below summarizes the differences in capabilities, between the
    545 publisher account, a test account, and any other account.</p>
    546 
    547 <p class="table-caption" id="acct-types-table"><strong>Table 1.</strong>
    548 Differences in account types for testing licensing.</p>
    549 
    550 <table>
    551 <tr>
    552 <th>Account Type</th>
    553 <th>Can check license before upload?</th>
    554 <th>Can receive test response?</th>
    555 <th>Can set test response?</th>
    556 </tr>
    557 
    558 <tr>
    559 <td>Publisher account</td>
    560 <td>Yes</td>
    561 <td>Yes</td>
    562 <td>Yes</td>
    563 </tr>
    564 
    565 <tr>
    566 <td>Test account</td>
    567 <td>No</td>
    568 <td>Yes</td>
    569 <td>No</td>
    570 </tr>
    571 
    572 <tr>
    573 <td>Other</td>
    574 <td>No</td>
    575 <td>No</td>
    576 <td>No</td>
    577 </tr>
    578 </table>
    579 
    580 <h4 id="reg-test-acct">Registering test accounts on the publisher account</h4>
    581 
    582 <p>To get started, you need to register each test account in your publisher
    583 account. As shown in Figure 4, you
    584 register test accounts in the Licensing panel of your publisher account's Edit
    585 Profile page. Simply enter the accounts as a comma-delimited list and click
    586 <strong>Save</strong> to save your profile changes.</p>
    587 
    588 <p>You can use any Google account as a test account. If you want to own and
    589 control the test accounts, you can create the accounts yourself and distribute
    590 the credentials to your developers or testers.</p>
    591 
    592 <h4 id="test-app-upload">Handling application upload and distribution for test
    593 account users</h4>
    594 
    595 <p>As mentioned above, users of test accounts can only receive static test
    596 responses for applications that are uploaded to the publisher account. Since
    597 those users do not have permission to upload applications, as the publisher you
    598 will need to work with those users to collect apps for upload and distribute
    599 uploaded apps for testing. You can handle collection and distribution in any way
    600 that is convenient. </p>
    601 
    602 <p>Once an application is uploaded and becomes known to the licensing server,
    603 developers and testers can continue modify the application in their local
    604 development environment, without having to upload new versions. You only need to
    605 upload a new version if the local application increments the
    606 <code>versionCode</code> attribute in the manifest file. </p>
    607 
    608 <h4 id="test-key">Distributing your public key to test account users</h4>
    609 
    610 <p>The licensing server handles static test responses in the normal way,
    611 including signing the license response data, adding extras parameters, and so
    612 on. To support developers who are implementing licensing using test accounts,
    613 rather than the publisher account, you will need to distribute
    614 your public key to them. Developers without access to the publisher site do not
    615 have access to your public key, and without the key they won't be able to
    616 verify license responses. </p>
    617 
    618 <p>Note that if you decide to generate a new licensing key pair for your account
    619 for some reason, you need to notify all users of test accounts. For
    620 testers, you can embed the new key in the application package and distribute it
    621 to users. For developers, you will need to distribute the new key to them
    622 directly. </p>
    623 
    624 
    625 <h3 id="acct-signin">Signing in to an authorized account in the runtime
    626 environment</h3>
    627 
    628 <p>The licensing service is designed to determine whether a given user is
    629 licensed to use a given application &mdash; during a license check, the Google
    630 Play application gathers the user ID from the primary account on the system
    631 and sends it to the server, together with the package name of the application
    632 and other information. However, if there is no user information available, the
    633 license check cannot succeed, so the Google Play application terminates the
    634 request and returns an error to the application. </p>
    635 
    636 <p>During testing, to ensure that your application can successfully query the
    637 licensing server, you must make sure that you sign in to an account <em>on the
    638 device or emulator</em> using:</p>
    639 
    640 <ul>
    641 <li>The credentials of a publisher account, or</li>
    642 <li>The credentials of a test account that is registered with a publisher
    643 account</li>
    644 </ul>
    645 
    646 
    647 <div class="sidebox-wrapper">
    648 <div class="sidebox">
    649 <h2>Signing in to a Google account on an emulator</h2>
    650 
    651 <p>If you are testing licensing on an emulator, you need to sign in to a Google
    652 account on the emulator. If you do not see an option to create a new Google
    653 account, the problem might be that your AVD is running a standard Android system
    654 image, rather than the Google APIs Add-On, API 8 (release 2) or higher. </p>
    655 
    656 <p style="margin-top:.5em;">For more information, see <a
    657 href="#runtime-setup">Setting up the runtime environment</a>, above.</p>
    658 
    659 </div>
    660 </div>
    661 
    662 <p>Signing in using a publisher account offers the advantage of letting your
    663 applications receive static test responses even before the applications are
    664 uploaded to the publisher site.</p>
    665 
    666 <p>If you are part of a larger organization or are working with external groups
    667 on applications that will be published through your site, you will more likely
    668 want to distribute test accounts instead, then use those to sign in during
    669 testing. </p>
    670 
    671 <p>To sign in on a device or emulator, follow the steps below. The preferred
    672 approach is to sign in as the primary account &mdash; however, if there are
    673 other accounts already in use on the device or emulator, you can create an
    674 additional account and sign in to it using the publisher or test account
    675 credentials.  </p>
    676 
    677 <ol>
    678 <li>Open Settings &gt; Accounts &amp; sync</li>
    679 <li>Select <strong>Add Account</strong> and choose to add a Google account.
    680 </li>
    681 <li>Select <strong>Next</strong> and then <strong>Sign in</strong>.</li>
    682 <li>Enter the username and password of either the publisher account or a test
    683 account that is registered in the publisher account.</li>
    684 <li>Select <strong>Sign in</strong>. The system signs you in to the new
    685 account.</li>
    686 </ol>
    687 
    688 <p>Once you are signed in, you can begin testing licensing in your application
    689 (if you have completed the LVL integration steps above). When your application
    690 initiates a license check, it will receive a response containing the static test
    691 response configured on the publisher account. </p>
    692 
    693 <p>Note that, if you are using an emulator, you will need to sign in to the
    694 publisher account or test account each time you wipe data when restarting the
    695 emulator.</p>
    696 
    697 <p>Once you've completed the setup procedures, continue to <a
    698 href="{@docRoot}guide/google/play/licensing/adding-licensing.html">Adding Licensing to Your App</a>.</p>
    699 
    700 
    701 
    702