title: Android Licensing Error 561 -This application is not licensed. Please purchase it from Android Market
body: <p>I have no clue whether am I doing a correct implementation of LVL.<br>
  Please guide me with this issue.  </p>
  
  <p>I followed some of the answers like clearing the cache, uninstalling and reinsatlling.<br>
  Still no luck..</p>
  
  <p>I tried the following steps before uploading to alpha testing.</p>
  
  <ol>
  <li>I am using Eclipse. I created a keystore using the export signed application package option  </li>
  <li>Uploaded the APK from the keystore.</li>
  </ol>
  
  <p>Following is my code, which I took from <a href="https://stackoverflow.com/questions/7452332/how-to-license-my-android-application">How to license my Android application?</a></p>
  
  <pre><code>public class Activity_LicenseCheck extends Activity {
      private class MyLicenseCheckerCallback implements LicenseCheckerCallback{
      @Override
      public void allow(int reason) {
            toast("Inside-Allow:" + reason);
           if (isFinishing()) {
               // Don't update UI if Activity is finishing.
               return;
              }
           startMainActivity();
  
      }
  
      @Override
      public void dontAllow(int reason) {
  
            toast("dontAllow: " + reason);
          if (isFinishing()) {
                  // Don't update UI if Activity is finishing.
                  return;
              }
  
  
      }
  
      @Override
      public void applicationError(int errorCode) {
           if (isFinishing()) {
                  return;
              }
  
              toast("Errorffff: " + errorCode);
              startMainActivity();
  
      }
  
      }
      private static final String BASE64_PUBLIC_KEY = "mykey";
      private static final byte[] SALT = new byte[] {11,34,56,36,3,45,-87,2,67,-98,32,-14,44,-58,39,-26,72,-19,86,23};
      private LicenseChecker mChecker;
  
      // A handler on the UI thread.
  
      private LicenseCheckerCallback mLicenseCheckerCallback;
      private void doCheck() {
              mChecker.checkAccess(mLicenseCheckerCallback);
      }
  
      @Override
          public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      // Try to use more data here. ANDROID_ID is a single point of attack.
      String deviceId = Secure.getString(getContentResolver(),
              Secure.ANDROID_ID);
  
      // Library calls this when it's done.
      mLicenseCheckerCallback = new MyLicenseCheckerCallback();
      // Construct the LicenseChecker with a policy.
      mChecker = new LicenseChecker(this, new ServerManagedPolicy(this,
              new AESObfuscator(SALT, getPackageName(), deviceId)),
              BASE64_PUBLIC_KEY);
              doCheck();
          }
  
      @Override
          protected Dialog onCreateDialog(int id) {
      // We have only one dialog.
      return new AlertDialog.Builder(this)
              .setTitle("Application Not Licensed")
              .setCancelable(false)
              .setMessage(
                      "This application is not licensed. Please purchase it from Android Market")
              .setPositiveButton("Buy App",
                      new DialogInterface.OnClickListener() {
                          @Override
                          public void onClick(DialogInterface dialog,
                                  int which) {
                              Intent marketIntent = new Intent(
                                      Intent.ACTION_VIEW,
                                      Uri.parse("http://market.android.com/details?id="
                                              + getPackageName()));
                              startActivity(marketIntent);
                              finish();
                          }
                      })
              .setNegativeButton("Exit",
                      new DialogInterface.OnClickListener() {
                          @Override
                          public void onClick(DialogInterface dialog,
                                  int which) {
                              finish();
                          }
                      }).create();
          }
          @Override
          protected void onDestroy() {
      super.onDestroy();
      mChecker.onDestroy();
          }
  
        private void startMainActivity() {
          startActivity(new Intent(this, Activity_login.class));  
          finish();
          }
  
          public void toast(String string) {
      Toast.makeText(this, string, Toast.LENGTH_SHORT).show();
          }
  }
  </code></pre>