REV更新后,许可检查崩溃 [英] License checker crashes after rev update

查看:148
本文介绍了REV更新后,许可检查崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

之前的一切是完美的...但是... 今天发生了一件事给我的授权检查(不碰线),这让我的应用程序崩溃。所以,我看到有该库可在程序包管理器的更新和更新(我已经更新的Eclipse太)。 我也更新了方法,以使它们与新的更新工作。 它的工作了几个小时。 在此之后停止工作了一些Eclipse的开/关周期(它编译但崩溃):

这是LicenseCheck.java:

 包it.android.smartscreenoffpro;

/ *
 * @author尼克·尤班克斯
 *
 *版权所有(C)2010安卓无限(http://www.androidinfinity.com)
 *
 * /
进口android.app.Activity;
进口android.app.AlertDialog;
进口android.app.Dialog;
进口android.content.DialogInterface;
进口android.content.Intent;
进口android.net.Uri;
进口android.os.Bundle;
进口android.provider.Settings.Secure;
进口android.widget.Toast;

进口com.google.android.vending.licensing.AESObfuscator;
进口com.google.android.vending.licensing.LicenseChecker;
进口com.google.android.vending.licensing.LicenseCheckerCallback;
进口com.google.android.vending.licensing.ServerManagedPolicy;

/ *
 *关于使用此许可证文件在你的应用:
 * 1.定义包
 *你上面的应用
 * 2.确保您的公共密钥设置正确@ BASE64_PUBLIC_KEY
 * 3。使用随机数字更改SALT
 * 4.在AllowAccess,添加您的previously使用MainActivity
 * 5.添加此活动
 *你的清单,并设置意图过滤器来MAIN和LAUNCHER
 * 6.从previous主要活动删除意图过滤器
 * /
公共类LicenseCheck延伸活动{
    私有类MyLicenseCheckerCallback实现LicenseCheckerCallback {

        公共无效允许(INT原因){
            如果(isFinishing()){
                //不要更新UI,如果活动是整理。
                返回;
            }
            //应该允许用户访问。
            startMainActivity();

        }


        公共无效的ApplicationError(INT错误code){
            如果(isFinishing()){
                //不要更新UI,如果活动是整理。
                返回;
            }
            //这句话的意思开发商弄错了一种礼貌的方式
            //在设置或致电许可证检查程序库。
            //请检查错误code和修复错误。
            吐司(错误:+错误code);
            startMainActivity();

        }

        公共无效dontAllow(INT原因){
            如果(isFinishing()){
                //不要更新UI,如果活动是整理。
                返回;
            }

            //不应该允许访问。在大多数情况下,该应用应该假设
            //用户具有访问权限,除非遇到这一点。如果这样做,
            //应用程序应该通知他们无牌方式的用户
            //然后或者关闭该应用或限制用户以
            //限制的功能集。
            //在这个例子中,我们显示一个对话框,将用户带到市场。
            的ShowDialog(0);
        }
    }
    私有静态最后弦乐BASE64_PUBLIC_KEY =这可能是最好不要来发表您的钥匙在这样的地方。

    私有静态最后一个字节[]盐=新的字节[] {-​​90,65,70,-128,-103,-57,74,-64,51,99,
        -95,-5,100,97,-35,-113,-14,32,-64,89};
    私人LicenseChecker mChecker;

    // UI线程处理程序。

    私人LicenseCheckerCallback mLicenseCheckerCallback;

    私人无效doCheck(){

        mChecker.checkAccess(mLicenseCheckerCallback);
    }

    @覆盖
    公共无效的onCreate(包savedInstanceState){
        super.onCreate(savedInstanceState);

        //尝试在这里使用更多的数据。 ANDROID_ID是一个攻击点。
        字符串的DeviceID = Secure.getString(getContentResolver()
                Secure.ANDROID_ID);

        //库调用这个当它这样做。
        mLicenseCheckerCallback =新MyLicenseCheckerCallback();
        //构造一个政策LicenseChecker。
        mChecker =新LicenseChecker(这一点,新ServerManagedPolicy(这一点,
                新AESObfuscator(SALT,getPackageName(),DEVICEID)),
                BASE64_PUBLIC_KEY);
        doCheck();

    }

    @覆盖
    受保护的对话框onCreateDialog(INT ID){
        //我们只有一个对话框。
        返回新AlertDialog.Builder(本)
                .setTitle(申请未获许可)
                .setCancelable(假)
                .setMessage(
                        这个应用程序是不许可的。请确保您连接到互联网。请从Android Market购买它)
                .setPositiveButton(购买应用程序,
                        新DialogInterface.OnClickListener(){
                            公共无效的onClick(DialogInterface对话框,
                                    其中INT){
                                意图marketIntent =新的意图(
                                        Intent.ACTION_VIEW,
                                        Uri.parse(http://market.android.com/details?id=
                                                + getPackageName()));
                                startActivity(marketIntent);
                                完();
                            }
                        })
                .setNegativeButton(退出,
                        新DialogInterface.OnClickListener(){
                            公共无效的onClick(DialogInterface对话框,
                                    其中INT){
                                完();
                            }
                        })。创建();
    }

    @覆盖
    保护无效的onDestroy(){
        super.onDestroy();
        mChecker.onDestroy();
    }

    私人无效startMainActivity(){
        startActivity(新意图(这一点,ActivityPrincipale.class)); //更换MainActivity.class与您的应用程序原LAUNCH活动
        完();
    }

    公共无效吐司(字符串字符串){
        Toast.makeText(这一点,字符串,Toast.LENGTH_SHORT).show();
    }
 

这是运行时错误是:

  03-16 16:53:59.198:E / AndroidRuntime(29719):致命异常:主要
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):在it.android.smartscreenoffpro.LicenseCheck.onCreate(LicenseCheck.java:101)
03-16 16:53:59.198:E / AndroidRuntime(29719):在android.app.Activity.performCreate(Activity.java:4465)
03-16 16:53:59.198:E / AndroidRuntime(29719):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
03-16 16:53:59.198:E / AndroidRuntime(29719):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
03-16 16:53:59.198:E / AndroidRuntime(29719):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
03-16 16:53:59.198:E / AndroidRuntime(29719):在android.app.ActivityThread.access $ 600(ActivityThread.java:123)
03-16 16:53:59.198:E / AndroidRuntime(29719):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1147)
03-16 16:53:59.198:E / AndroidRuntime(29719):在android.os.Handler.dispatchMessage(Handler.java:99)
03-16 16:53:59.198:E / AndroidRuntime(29719):在android.os.Looper.loop(Looper.java:137)
03-16 16:53:59.198:E / AndroidRuntime(29719):在android.app.ActivityThread.main(ActivityThread.java:4424)
03-16 16:53:59.198:E / AndroidRuntime(29719):在java.lang.reflect.Method.invokeNative(本机方法)
03-16 16:53:59.198:E / AndroidRuntime(29719):在java.lang.reflect.Method.invoke(Method.java:511)
03-16 16:53:59.198:E / AndroidRuntime(29719):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:784)
03-16 16:53:59.198:E / AndroidRuntime(29719):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-16 16:53:59.198:E / AndroidRuntime(29719):在dalvik.system.NativeStart.main(本机方法)
 

解决方案

开始自动工作。

Everything before was perfect... but... Today something happened to my License checker (without touching a line) and that made my app crash. So I saw there was an update available on the Package Manager for that library and updated (I've updated Eclipse too). I've also updated the methods in order to make them work with the new update. It worked for a couple of hours. After some Eclipse open/close cycle that stop working again (it compiles but crashes):

This is the 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();
    }

This is the runtime error:

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)

解决方案

Started worked automatically .

这篇关于REV更新后,许可检查崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆