Android的应用内结算:Security.java说:"签名验证失败"Security、Android、QUOT、java

2023-09-05 08:51:43 作者:烟碎雨落花甽醉

我已经实现了与Android的应用内计费测试应用程序。我填补了我在Security.java文件公钥。一切正常,但是当我提交了支付,应用程序崩溃。我收到LogCat中的错误,指出签名验证失败,它对应于该位的code:

I have implemented a test app with Android's In-App Billing. I have filled in my Public Key in the Security.java file. Everything works, but when I submit the payment, the app crashes. I receive an error in LogCat that says "Signature Verification Failed", which corresponds to this bit of code:

if (!sig.verify(Base64.decode(signature))) {
                Log.e(TAG, "Signature verification failed.");
                return false;
}

如果我改变该位返回,而不是返回假假真真,然后一切工作正常 - 我可以提交付款并安全返回到应用程序 - 但我假设别的东西是错误的,因为我也许应该改变,要返回真的。

If I change that bit to return true instead of return false, then everything works properly - I can submit payment and safely return to the app - but I am assuming that something else is wrong, since I probably should change that to return true.

任何关于这可能是造成这种想法?

Any ideas about what could be causing this?

推荐答案

这签名验证错误可能由下列原因造成:

That signature verification error can be caused by:

1:一个错误的公钥。也许你已经忘记复制一些字符。它发生:)

1.- A wrong public key. Maybe you've forgotten to copy some character. It happens :)

2: 的apk文件必须签名 。你不能使用debug.keystore,如果你做你的签名字符串将是空的。

2.- The .apk must be signed. You can't use the debug.keystore, if you do your signature string will be empty.

记住,用于测试应用内计费方式:

And remember, for testing In-app billing:

加入Android Market的公钥来Security.java(字符串base64En codedPublicKey =在这里你的公钥

建立在释放模式并签字(如果你使用的是Eclipse,您可以使用导出向导)。

Build in release mode and sign it (If you are using Eclipse, you can use the Export Wizard).

上传的发行版本的Andr​​oid市场,不发布,并创建产品清单。

Upload the release version to Android Market, do not publish it, and create the product list.

应用程序安装到您的设备(ADB -d安装myapp.apk),并测试帐户的主设备上。

Install the application onto your device ( adb -d install myapp.apk ) and make a test account primary on your device.