java.lang.IllegalArgumentException: java.security.spec.InvalIDKeySpecException: java.lang.RuntimeException: error:0D07209B:asn1 enCoding routines:ASN1_get_object:too longat com.nightowl.memory.Security.generatePublicKey(Security.java:85)at com.nightowl.memory.Security.verifyPurchase(Security.java:65)at com.nightowl.memory.IabHelper.queryPurchases(IabHelper.java:875)at com.nightowl.memory.IabHelper.queryInventory(IabHelper.java:550)at com.nightowl.memory.IabHelper.queryInventory(IabHelper.java:528)at com.nightowl.memory.IabHelper.run(IabHelper.java:623)at java.lang.Thread.run(Thread.java:841)Caused by: java.security.spec.InvalIDKeySpecException: java.lang.RuntimeException: error:0D07209B:asn1 enCoding routines:ASN1_get_object:too longat com.androID.org.conscrypt.OpenSSLKey.getPublicKey(OpenSSLKey.java:101)at com.androID.org.conscrypt.OpenSSlrsAKeyFactory.engineGeneratePublic(OpenSSlrsAKeyFactory.java:47)at java.security.KeyFactory.generatePublic(KeyFactory.java:171)at com.nightowl.memory.Security.generatePublicKey(Security.java:80)... 6 moreCaused by: java.lang.RuntimeException: error:0D07209B:asn1 enCoding routines:ASN1_get_object:too longat com.androID.org.conscrypt.NativeCrypto.d2i_PUBKEY(Native Method)at com.androID.org.conscrypt.OpenSSLKey.getPublicKey(OpenSSLKey.java:99)... 9 more
我使用以下代码来调用它:
String base64EncodedPublicKey; base64EncodedPublicKey= String.valueOf(R.string.myPubKey); additionalSkuList = new ArrayList<String>(); for(int i=0;i<3;i++) { for(int j=0;j<4;j++) { if(i==0&&j>1) break; additionalSkuList.add(ID[i][j]); } } mHelper = new IabHelper(this,base64EncodedPublicKey); mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { public voID onIabSetupFinished(IabResult result) { Log.d("main","m here"); if (!result.isSuccess()) { // Oh noes,there was a problem. Log.d("main","Problem setting up in-app Billing: " + result); } // Hooray,IAB is fully set up! isIAB = true; mHelper.queryInventoryAsync(true,additionalSkuList,mqueryFinishedListener); Log.d("main","" + isIAB + " " + isLoad); } });IabHelper.queryInventoryFinishedListener mqueryFinishedListener = new IabHelper.queryInventoryFinishedListener() { public voID onqueryInventoryFinished(IabResult result,Inventory inventory) { Log.d("main","m here too"); if (result.isFailure()) { // handle error return; } for(int i=0;i<3;i++) { for(int j=0;j<4;j++) { if(i==0&&j>1) break; price[i][j]=inventory.getSkuDetails(ID[i][j]).getPrice(); } } isLoad=true; data.setPrice(price); data.setDataLoad(true); // update the UI } }; public voID onPurchaseCall() { int loc[] = data.getItem(); mHelper.launchPurchaseFlow(this,ID[loc[0]][loc[1]],100*loc[0]+loc[1],mpurchaseFinishedListener,ID[loc[0]][loc[1]]); } IabHelper.OnIabPurchaseFinishedListener mpurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() { public voID onIabPurchaseFinished(IabResult result,Purchase purchase) { if (result.isFailure()) { Log.d("main","Error purchasing: " + result); return; } else if (purchase.getSku().equals(ID[0][0])) { data.setNoads(1); mAdVIEw.setVisibility(VIEw.INVISIBLE); data.setNotificationState(1); data.setNoOfnotifications(2); data.setNotificationMsg(0,"Purchase Complete"); data.setNotificationMsg(1,PurchaseMsg[0]); // consume the gas and update the UI } } };
任何人都可以帮我解决吗?我从日志中猜到的是我提供的公钥存在问题.但它第一次起作用(直到我成功购买才开始工作).我还得到了所有应用内商品的价目表.
我试图用测试帐户测试购买.成功完成购买后出现此错误,从那时起该应用程序未针对该帐户运行.
解决方法 不要使用String.valueOf(R.string.myPubKey),它会给你一个错误的值.而是使用getResources().getString(R.string.myPubKey_data))来获取您的公钥字符串. 总结以上是内存溢出为你收集整理的Android In-App Billing Error InvalidKeySpecException全部内容,希望文章能够帮你解决Android In-App Billing Error InvalidKeySpecException所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)