2

I have no clue whether am I doing a correct implementation of LVL.
Please guide me with this issue.

I followed some of the answers like clearing the cache, uninstalling and reinsatlling.
Still no luck..

I tried the following steps before uploading to alpha testing.

  1. I am using Eclipse. I created a keystore using the export signed application package option
  2. Uploaded the APK from the keystore.

Following is my code, which I took from How to license my Android application?

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();
        }
}
Community
  • 1
  • 1
dc2015
  • 41
  • 7

1 Answers1

1

Finally it worked the issue was the wrong entry of BASE64 PUBLIC KEY.I was completely clueless about the licencing concept google should come up with easy solution.

How it worked for me.. My first publish was ver 1.0 and i was getting error 561.(Not licenced) the isuue was wrong BASE64 PUBLIC KEY entry then i replaced it with the correct one and changed application version to 2.0 in Androidmanifest.xml and regenerated keystore and finally uploaded apk to the developer console and disabled version 1 and published version 2 in the console. when downloaded new apk from the console still facing issue the app was throwing "Error retrieving information from server [RPC:S-7:AEC-0]" error. i googled and found the solution, rebooted the device and it worked

dc2015
  • 41
  • 7