Android 版本更新后许可证检查器崩溃

Android 版本更新后许可证检查器崩溃,android,android-activity,android-lvl,Android,Android Activity,Android Lvl,以前的一切都很完美。。。但是 今天,我的许可证检查器出了点问题(一句话也没说),这让我的应用程序崩溃了。因此,我看到该库的包管理器上有一个可用的更新,并进行了更新(我也更新了Eclipse)。 我还更新了这些方法,使它们能够与新的更新一起工作。 它工作了几个小时。 在某个Eclipse打开/关闭周期后再次停止工作(它编译但崩溃): 这是LicenseCheck.java: package it.android.smartscreenoffpro; /* * @author Nick Euba

以前的一切都很完美。。。但是 今天,我的许可证检查器出了点问题(一句话也没说),这让我的应用程序崩溃了。因此,我看到该库的包管理器上有一个可用的更新,并进行了更新(我也更新了Eclipse)。 我还更新了这些方法,使它们能够与新的更新一起工作。 它工作了几个小时。 在某个Eclipse打开/关闭周期后再次停止工作(它编译但崩溃):

这是LicenseCheck.java:

package it.android.smartscreenoffpro;

/*
 * @author Nick Eubanks
 * 
 * Copyright (C) 2010 Android Infinity (http://www.androidinfinity.com)
 *
 */
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings.Secure;
import android.widget.Toast;

import com.google.android.vending.licensing.AESObfuscator;
import com.google.android.vending.licensing.LicenseChecker;
import com.google.android.vending.licensing.LicenseCheckerCallback;
import com.google.android.vending.licensing.ServerManagedPolicy;

/*
 * NOTES ON USING THIS LICENSE FILE IN YOUR APPLICATION: 
 * 1. Define the package
 * of you application above 
 * 2. Be sure your public key is set properly  @BASE64_PUBLIC_KEY
 * 3. Change your SALT using random digits 
 * 4. Under AllowAccess, Add your previously used MainActivity 
 * 5. Add this activity to
 * your manifest and set intent filters to MAIN and LAUNCHER 
 * 6. Remove Intent Filters from previous main activity
 */
public class LicenseCheck extends Activity {
    private class MyLicenseCheckerCallback implements LicenseCheckerCallback {

        public void allow(int reason) {
            if (isFinishing()) {
                // Don't update UI if Activity is finishing.
                return;
            }
            // Should allow user access.
            startMainActivity();

        }


        public void applicationError(int errorCode) {
            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.
            toast("Error: " + errorCode);
            startMainActivity();

        }

        public void dontAllow(int reason) {
            if (isFinishing()) {
                // Don't update UI if Activity is finishing.
                return;
            }

            // 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.
            showDialog(0);
        }
    }
    private static final String BASE64_PUBLIC_KEY = "It is probably better not to post your key in a place like this.";

    private static final byte[] SALT = new byte[] {-90, 65, 70, -128, -103, -57, 74, -64, 51, 99,
        -95, -5, 100, 97, -35, -113, -14, 32, -64, 89};
    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. Make sure you are connected to Internet. Please purchase it from Android Market")
                .setPositiveButton("Buy App",
                        new DialogInterface.OnClickListener() {
                            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() {
                            public void onClick(DialogInterface dialog,
                                    int which) {
                                finish();
                            }
                        }).create();
    }

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

    private void startMainActivity() {
        startActivity(new Intent(this, ActivityPrincipale.class));  //REPLACE MainActivity.class WITH YOUR APPS ORIGINAL LAUNCH ACTIVITY
        finish();
    }

    public void toast(String string) {
        Toast.makeText(this, string, Toast.LENGTH_SHORT).show();
    }
这是运行时错误:

03-16 16:53:59.198: E/AndroidRuntime(29719): FATAL EXCEPTION: main
03-16 16:53:59.198: E/AndroidRuntime(29719): java.lang.NoClassDefFoundError: it.android.smartscreenoffpro.LicenseCheck$MyLicenseCheckerCallback
03-16 16:53:59.198: E/AndroidRuntime(29719):    at it.android.smartscreenoffpro.LicenseCheck.onCreate(LicenseCheck.java:101)
03-16 16:53:59.198: E/AndroidRuntime(29719):    at android.app.Activity.performCreate(Activity.java:4465)
03-16 16:53:59.198: E/AndroidRuntime(29719):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
03-16 16:53:59.198: E/AndroidRuntime(29719):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
03-16 16:53:59.198: E/AndroidRuntime(29719):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
03-16 16:53:59.198: E/AndroidRuntime(29719):    at android.app.ActivityThread.access$600(ActivityThread.java:123)
03-16 16:53:59.198: E/AndroidRuntime(29719):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
03-16 16:53:59.198: E/AndroidRuntime(29719):    at android.os.Handler.dispatchMessage(Handler.java:99)
03-16 16:53:59.198: E/AndroidRuntime(29719):    at android.os.Looper.loop(Looper.java:137)
03-16 16:53:59.198: E/AndroidRuntime(29719):    at android.app.ActivityThread.main(ActivityThread.java:4424)
03-16 16:53:59.198: E/AndroidRuntime(29719):    at java.lang.reflect.Method.invokeNative(Native Method)
03-16 16:53:59.198: E/AndroidRuntime(29719):    at java.lang.reflect.Method.invoke(Method.java:511)
03-16 16:53:59.198: E/AndroidRuntime(29719):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-16 16:53:59.198: E/AndroidRuntime(29719):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-16 16:53:59.198: E/AndroidRuntime(29719):    at dalvik.system.NativeStart.main(Native Method)

启动时自动工作。

引发的错误是classnotfound异常,您确定应用程序中没有丢失任何库文件吗?它工作得很好,然后我关闭了Eclipse并停止工作。。。编译器也没有给出任何错误。