2011-06-06 3 views
1

J'essaie actuellement de mettre en œuvre le LVL de Google dans mon fond d'écran, mais semble avoir rencontré un problème avec une exception que je ne connais pas. J'ai trouvé cette Question qui m'a beaucoup aidé, LVL licensing in a Live Wallpaper?. Une des suggestions est de placer le code dans le moteur et j'ai choisi de le placer dans la classe ci-dessus. Le code semble bien se compiler mais à l'exécution je reçois une exception, apparemment pour ma clé publique.Bibliothèque de vérification des licences dans le papier peint

FATAL EXCEPTION: main 
java.lang.RuntimeException: Unable to create service <my package>.MyWallpaper: java.lang.IllegalArgumentException: java.security.spec.InvalidKeySpecException: java.io.IOException: corrupted stream - out of bounds length found 
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2076) 
at android.app.ActivityThread.access$2500(ActivityThread.java:123) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:993) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:130) 
at android.app.ActivityThread.main(ActivityThread.java:3835) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:507) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: java.lang.IllegalArgumentException: java.security.spec.InvalidKeySpecException: java.io.IOException: corrupted stream - out of bounds length found 
at com.android.vending.licensing.LicenseChecker.generatePublicKey(LicenseChecker.java:121) 
at com.android.vending.licensing.LicenseChecker.<init>(LicenseChecker.java:92) 
at com.metastable.epicvis.vis1.ScopeVisualizer.onCreate(ScopeVisualizer.java:41) 
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2066) 
... 10 more 
Caused by: java.security.spec.InvalidKeySpecException: java.io.IOException: corrupted stream - out of bounds length found 
at org.bouncycastle.jce.provider.JDKKeyFactory.engineGeneratePublic(JDKKeyFactory.java:92) 
at org.bouncycastle.jce.provider.JDKKeyFactory$RSA.engineGeneratePublic(JDKKeyFactory.java:396) 
at java.security.KeyFactory.generatePublic(KeyFactory.java:177) 
at com.android.vending.licensing.LicenseChecker.generatePublicKey(LicenseChecker.java:112) 
... 13 more 

Voici le code que j'utilise:

public class MyWallpaper extends WallpaperService implements LicenseCheckerCallback { 

private LicenseChecker mChecker; 
private static final String BASE64_PUBLIC_KEY = "My public key from google"; 
private byte[] salt = new byte[] {<20 random int>}; 
private String deviceId; 
private AESObfuscator aes; 


@Override 
public void onCreate() { 
    super.onCreate(); 
    deviceId = Secure.getString(getContentResolver(), Secure.ANDROID_ID); 
    aes = new AESObfuscator(salt, getPackageName(), deviceId); 
    mChecker = new LicenseChecker(this, new ServerManagedPolicy(this, aes), BASE64_PUBLIC_KEY); 
    mChecker.checkAccess(this); 
} 

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

@Override 
public Engine onCreateEngine() { 
    return new VisualizerEngine(); 
} 

class MyEngine extends Engine implements SharedPreferences.OnSharedPreferenceChangeListener { 
     <Unrelevant code removed> 
} 

@Override 
public void allow() { 
    Toast.makeText(this, "Allowed", Toast.LENGTH_SHORT); 

} 

@Override 
public void dontAllow() { 
    Toast.makeText(this, "Not Allowed", Toast.LENGTH_SHORT); 

} 

@Override 
public void applicationError(ApplicationErrorCode errorCode) { 
    // TODO Auto-generated method stub 

} 

} 

Y at-il une certaine façon je formater ma clé publique ou est-ce quelque chose de tout à fait différent?

L'exception provient de: mChecker = new LicenseChecker (this, new ServerManagedPolicy (this, aes), BASE64_PUBLIC_KEY);

Un conseil serait grandement apprécié.

Répondre

1

J'ai depuis compris le problème, apparemment je suis terrible et copier et coller. Au lieu de cliquer glisser et de sélectionner ma clé, ce que j'ai fait de nombreuses fois et a continué à échouer, j'ai simplement triplé et il a copié correctement. Il h.

Questions connexes