今天做应用内支付功能,发现官方给的Sample 运行后出现一个问题,在交易完成后,程序 crash,异常信息如下:
04-05 11:02:58.862: I/ActivityManager(144): Start proc com.example.dungeons for service com.example.dungeons/.BillingService: pid=1804 uid=10060 gids={}
04-05 11:02:58.922: E/Security(1804):
Base64 decoding failed.
04-05 11:02:58.922: D/AndroidRuntime(1804): Shutting down VM
04-05 11:02:58.922: W/dalvikvm(1804): threadid=1: thread exiting with uncaught exception (group=0x401e4568)
04-05 11:02:58.932: E/AndroidRuntime(1804): FATAL EXCEPTION: main
04-05 11:02:58.932: E/AndroidRuntime(1804):
java.lang.RuntimeException: Unable to start service com.example.dungeons.BillingService@406e76c8 with Intent { act=com.android.vending.billing.PURCHASE_STATE_CHANGED cmp=com.example.dungeons/.BillingService
(has extras) }: java.lang.IllegalArgumentException: com.example.dungeons.util.Base64DecoderException: single trailing character at offset 19
04-05 11:02:58.932: E/AndroidRuntime(1804):
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2060)
04-05 11:02:58.932: E/AndroidRuntime(1804):
at android.app.ActivityThread.access$2800(ActivityThread.java:117)
04-05 11:02:58.932: E/AndroidRuntime(1804):
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:994)
04-05 11:02:58.932: E/AndroidRuntime(1804):
at android.os.Handler.dispatchMessage(Handler.java:99)
04-05 11:02:58.932: E/AndroidRuntime(1804):
at android.os.Looper.loop(Looper.java:130)
04-05 11:02:58.932: E/AndroidRuntime(1804):
at android.app.ActivityThread.main(ActivityThread.java:3694)
04-05 11:02:58.932: E/AndroidRuntime(1804):
at java.lang.reflect.Method.invokeNative(Native Method)
04-05 11:02:58.932: E/AndroidRuntime(1804):
at java.lang.reflect.Method.invoke(Method.java:507)
04-05 11:02:58.932: E/AndroidRuntime(1804):
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
04-05 11:02:58.932: E/AndroidRuntime(1804):
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
04-05 11:02:58.932: E/AndroidRuntime(1804):
at dalvik.system.NativeStart.main(Native Method)
04-05 11:02:58.932: E/AndroidRuntime(1804):
Caused by: java.lang.IllegalArgumentException: com.example.dungeons.util.Base64DecoderException: single trailing character at offset 19
04-05 11:02:58.932: E/AndroidRuntime(1804):
at com.example.dungeons.Security.generatePublicKey(Security.java:209)
04-05 11:02:58.932: E/AndroidRuntime(1804):
at com.example.dungeons.Security.verifyPurchase(Security.java:128)
04-05 11:02:58.932: E/AndroidRuntime(1804):
at com.example.dungeons.BillingService.purchaseStateChanged(BillingService.java:493)
04-05 11:02:58.932: E/AndroidRuntime(1804):
at com.example.dungeons.BillingService.handleCommand(BillingService.java:383)
04-05 11:02:58.932: E/AndroidRuntime(1804):
at com.example.dungeons.BillingService.onStart(BillingService.java:360)
04-05 11:02:58.932: E/AndroidRuntime(1804):
at android.app.Service.onStartCommand(Service.java:428)
04-05 11:02:58.932: E/AndroidRuntime(1804):
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2047)
04-05 11:02:58.932: E/AndroidRuntime(1804):
... 10 more
04-05 11:02:58.932: E/AndroidRuntime(1804):
Caused by: com.example.dungeons.util.Base64DecoderException: single trailing character at offset 19
04-05 11:02:58.932: E/AndroidRuntime(1804):
at com.example.dungeons.util.Base64.decode(Base64.java:559)
04-05 11:02:58.932: E/AndroidRuntime(1804):
at com.example.dungeons.util.Base64.decode(Base64.java:474)
04-05 11:02:58.932: E/AndroidRuntime(1804):
at com.example.dungeons.util.Base64.decode(Base64.java:420)
04-05 11:02:58.932: E/AndroidRuntime(1804):
at com.example.dungeons.Security.generatePublicKey(Security.java:199)
04-05 11:02:58.932: E/AndroidRuntime(1804): ... 16 more
solution:
是我自己的代码问题,我忘记了:第六条
Configuring and building the sample application
Before you can run the sample application, you need to configure it and build it by doing the following:
-
Add your Google Play public key to the sample application code.
This enables the application to verify the signature of the transaction information that is returned from Google Play. To add your public key to the sample application code, do the following:
-
Log in to your Google Playpublisher account.
-
On the upper left part of the page, under your name, clickEdit Profile.
-
On the Edit Profile page, scroll down to theLicensing & In-app Billingpanel.
-
Copy your public key.
-
Open
src/com/example/dungeons/Security.java
in the editor of your choice.
You can find this file in the sample application's project folder.
-
Add your public key to the following line of code:
String base64EncodedPublicKey = "your public key here";
-
Save the file.
-
Change the package name of the sample application.
The current package name iscom.example.dungeons
. Google Play does not let you upload applications with package names that containcom.example
,
so you must change the package name to something else.
-
Build the sample application in release mode and sign it.
To learn how to build and sign applications, seeBuilding and Running.
分享到:
相关推荐
android.util.Base64类
Android Base64Jar包及Java完整源码 包含:android android.util.Base64 类, BASE64编码、解码算法;包含该类的完整Jar包。 可以直接导入Jar包或者引用类及类中相关方法。 很不错的工具类。
真实的Android Base64的jar。下载既可以使用。在Java项目内亦可以。android-util-0.6.0.jar
Tomcat内存溢出的解决方法(java.util.concurrent.ExecutionException:java.lang.OutOfMemoryError),内附解决方案!
http://blog.csdn.net/yx0628/article/details/9633947 这个是gps转百度地图坐标的相关介绍。
Exception in thread “main“ java.util.InputMismatchException
java源码,base64转码解码,包括源码和jar包,图片或文件与base64互相转换。
org.apache.commons.net.util.jar
很详细的apache-tomcat-8.0.523月 17, 2019 10:51:41 上午 org.apache.tomcat.util.digester.SetPropertiesRule begin 警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' ...
予org.jasig.cas.client.util.CommonUtils 加入 public static void disableSSLVerification(){ try { // Create a trust manager that does not validate certificate chains TrustManager[] ...
at org.apache.spark.util.AkkaUtils$.org$apache$spark$util$AkkaUtils$$doCreateActorSystem(AkkaUtils.scala:121) at org.apache.spark.util.AkkaUtils$$anonfun$1.apply(AkkaUtils.scala:53) at org....
java.util.LinkedList$ListItr.checkForComodification(LinkedList.java:953) java.util.LinkedList$ListItr.next(LinkedList.java:886) JMeter.plugins.functional.samplers.websocket.ServiceSocket....
axis2解决 org.apache.axis2.util.JavaUtils.callStackToString问题
Puzzle 64: The Mod Squad Puzzle 65: A Strange Saga of a Suspicious Sort Chapter 8. Classier Puzzlers Puzzle 66: A Private Matter Puzzle 67: All Strung Out Puzzle 68: Shades of Gray Puzzle 69: Fade to ...
使用base64加解密的jar包,提供三种,对应就有三种方法。详细操作博客里有,不会的小伙伴可以自己去查看!啊啊啊啊,还不够100字。
base64utils jar 项目中应用,亲测,希望能帮到您,加油 少年
at com.sun.xml.ws.util.xml.XmlUtil.createEntityResolver(XmlUtil.java:266) at org.jvnet.jax_ws_commons.spring.SpringService.getObject(SpringService.java:327) at org.jvnet.jax_ws_commons.spring....
java.util.ConcurrentModificationException 异常问题详解1
Base64最好最全的jar包,支持字节数组 字符串String 互转。