2012-03-16 16 views
3

前のものはすべて完璧でした...しかし... 今日、私のライセンスチェッカーに何か問題が発生しました(回線に触れることなく)、アプリがクラッシュしました。そこで、そのライブラリのパッケージマネージャーでアップデートが利用可能であることがわかりました(アップデート済みのEclipseもあります)。 メソッドを更新して、新しい更新プログラムで動作させるようにしました。 それは数時間働いた。 (それがコンパイルされますが、クラッシュ)、再び作業を停止し、いくつかのEclipseのオープン/クローズサイクル後 :rev更新後にライセンスチェッカーがクラッシュする

これは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) 
+0

スローされるエラーは、classnotfound例外です。アプリケーションからlibファイルが失われていないことを確認してください。 – david99world

+0

それは偉大な作業だった、私はEclipseを閉じて、作業を停止...コンパイラは、あまりにもエラーを与えることはありません。 –

答えて

0

自動的に作業を開始しました。

関連する問題