Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8400421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:33:25+00:00 2026-06-09T21:33:25+00:00

I ask to find a problem in my code which crashes application. I have

  • 0

I ask to find a problem in my code which crashes application.
I have Licensing code and libgdx code which work okay as separate applications.
I added licensing code as is to main activity of the Libgdx project.
After that the application crashes on the device.
I have no idea why.

Logcat is as follows:

Logcat

Main activity code is here:

public class MyActivity extends AndroidApplication {
private static final String BASE64_PUBLIC_KEY = "!!!!! PLACE YOUR KEY HERE!!!!!!";


// Generate your own 20 random bytes, and put them here.
private static final byte[] SALT = new byte[] {
        -45, 65, 30, -128, -103, -57, 74, -64, 51, 88, -95, -45, 77, -117, -36, -113, -11, 32, -64,
        89
};

private TextView mStatusText;
private Button mCheckLicenseButton;

private LicenseCheckerCallback mLicenseCheckerCallback;
private LicenseChecker mChecker;
// A handler on the UI thread.
private Handler mHandler;



public void onCreate (android.os.Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    print("MyLog====","00000000000000000");

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.main);

    mStatusText = (TextView) findViewById(R.id.status_text);
    mCheckLicenseButton = (Button) findViewById(R.id.check_license_button);
    mCheckLicenseButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            doCheck();
        }
    });

    mHandler = new Handler();

    // 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);
    print("MyLog====","11111111111111");
    doCheck();


}

protected Dialog onCreateDialog(int id) {

    final boolean bRetry = id == 1;
    return new AlertDialog.Builder(this)
            .setTitle(R.string.unlicensed_dialog_title)
            .setMessage(bRetry ? R.string.unlicensed_dialog_retry_body : R.string.unlicensed_dialog_body)
            .setPositiveButton(bRetry ? R.string.retry_button : R.string.buy_button, new DialogInterface.OnClickListener() {
                boolean mRetry = bRetry;
                public void onClick(DialogInterface dialog, int which) {
                    if ( mRetry ) {
                        doCheck();
                    } else {
                        Intent marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(
                                "http://market.android.com/details?id=" + getPackageName()));
                        startActivity(marketIntent);
                    }
                }
            })
            .setNegativeButton(R.string.quit_button, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    finish();
                }
            }).create();

}

private void displayDialog(final boolean showRetry) {
    print("MyLog====","DisplayDialog");
    mHandler.post(new Runnable() {
        public void run() {
            setProgressBarIndeterminateVisibility(false);
            showDialog(showRetry ? 1 : 0);
            mCheckLicenseButton.setEnabled(true);
        }
    });

}


private void doCheck() {
    mCheckLicenseButton.setEnabled(false);
    setProgressBarIndeterminateVisibility(true);
    mStatusText.setText(R.string.checking_license);
    mChecker.checkAccess(mLicenseCheckerCallback);
}

private void displayResult(final String result) {
    print("MyLog====","3333333333333");

    mHandler.post(new Runnable() {
        public void run() {
            print("MyLog====","aaaaaaaaaaaa");
            mStatusText.setText(result);
            print("MyLog====","bbbbbbbb");
            setProgressBarIndeterminateVisibility(false);
            print("MyLog====","cccccccc");
            mCheckLicenseButton.setEnabled(true);
            print("MyLog====","ddddddd");
        }
    });
}


private class MyLicenseCheckerCallback implements LicenseCheckerCallback {
    public void allow(int policyReason) {
        print("MyLog====","444444444444444");
        if (isFinishing()) {
            // Don't update UI if Activity is finishing.
            return;
        }
        // Should allow user access.
        displayResult(getString(R.string.allow));
        // setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
       // initialize(new Game3(), false);

    }

    public void dontAllow(int policyReason) {
        print("MyLog====","55555555555555555");
        if (isFinishing()) {
            // Don't update UI if Activity is finishing.
            return;
        }
        //displayResult(getString(R.string.dont_allow));
        // Should not allow access. In most cases, the app should assume
        // the user has access unless it encounters this. If it does,
        // the app should inform the user of their unlicensed ways
        // and then either shut down the app or limit the user to a
        // restricted set of features.
        // In this example, we show a dialog that takes the user to Market.
        // If the reason for the lack of license is that the service is
        // unavailable or there is another problem, we display a
        // retry button on the dialog and a different message.
        displayDialog(policyReason == Policy.RETRY);
    }

    public void applicationError(int errorCode) {
        print("MyLog====","6666666666666666666666");
        if (isFinishing()) {
            // Don't update UI if Activity is finishing.
            return;
        }
        // This is a polite way of saying the developer made a mistake
        // while setting up or calling the license checker library.
        // Please examine the error code and fix the error.
        //if (errorCode==Policy.
        String result = String.format(getString(R.string.application_error), errorCode);
        displayResult(result);
        print("MyLog====","9999999999999999999");
        String msg="";
        if (errorCode==1) msg="1-NOT_LICENSED";
        if (errorCode==2) msg="2-LICENSED_OLD_KEY";
        if (errorCode==3) msg="3-ERROR_NOT_MARKET_MANAGED";
        if (errorCode==4) msg="4-ERROR_SERVER_FAILURE";
        if (errorCode==5) msg="5-ERROR_OVER_QUOTA";
        if (errorCode==6) msg="6-ERR";
        print("MyLog====",msg);

    }
}

@Override
protected void onDestroy() {
    super.onDestroy();
    mChecker.onDestroy();
}

I have erased my key from licensing code.
You should enter your code to try, otherewise it’ll be invalid key exception.
Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T21:33:26+00:00Added an answer on June 9, 2026 at 9:33 pm

    AndroidApplication requires you to initialize(...) or initializeForView(...) in onCreate(...). Since you didn’t include it above, I can only assume that it is missing in your code.

    If you need to have a native Android UI, you’ll need to use initializeForView(...) to get a LibGDX surface, then insert it into the view hierarchy. Alternatively, you can trigger the check from within your game via an interface.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an interesting (but frustraring) problem. I have an application which uses the
I have a web application, written in ColdFusion, which periodically starts using 100% of
i have big problem with explanation code under, meanwhile i made two loops function
I have the following code, which works fine on live site, but not on
I'd like to ask if someone had such a problem before. I have version
While many ask questions about where to find good books or tutorials, I'd like
I want to ask a basic question that I couldn't find in online tutorials.
I couldn't find a good answer for this question so I figured I'd ask.
I'm not really sure how to even ask the question, let alone find an
I have tried to ask a variant of this question before. I got some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.