Android in-app purchase flow broken - android

I'm trying to make in-app purchase flow work in my app. I use helper classes from http://developer.android.com/training/in-app-billing/preparing-iab-app.html (IabHelper etc.). Everything's fine until I make payment. When returning to activity, this exception is raised
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null,
request=10001, result=-1, data=Intent { (has extras) }} to activity
{com.sunlight.mangomonitor/com.sunlight.mangomonitor.PurchaseActivity}:
java.lang.IllegalArgumentException: java.security.spec.InvalidKeySpecException:
java.lang.RuntimeException: error:0D07209B:asn1 encoding routines:ASN1_get_object:too long
at android.app.ActivityThread.deliverResults(ActivityThread.java:3408)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3451)
at android.app.ActivityThread.access$1200(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1332)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5296)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalArgumentException: java.security.spec.InvalidKeySpecException:
java.lang.RuntimeException: error:0D07209B:asn1 encoding routines:ASN1_get_object:too long
at com.sunlight.mangomonitor.util.Security.generatePublicKey(Security.java:92)
at com.sunlight.mangomonitor.util.Security.verifyPurchase(Security.java:66)
at com.sunlight.mangomonitor.util.IabHelper.handleActivityResult(IabHelper.java:460)
at com.sunlight.mangomonitor.PurchaseActivity.onActivityResult(PurchaseActivity.java:145)
at android.app.Activity.dispatchActivityResult(Activity.java:5444)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3404)
... 11 more
Caused by: java.security.spec.InvalidKeySpecException: java.lang.RuntimeException:
error:0D07209B:asn1 encoding routines:ASN1_get_object:too long
at
org.apache.harmony.xnet.provider.jsse.OpenSSLRSAKeyFactory.engineGeneratePublic(OpenSSLRSAKeyF actory.java:52)
at java.security.KeyFactory.generatePublic(KeyFactory.java:171)
at com.sunlight.mangomonitor.util.Security.generatePublicKey(Security.java:87)
... 16 more
Caused by: java.lang.RuntimeException: error:0D07209B:asn1 encoding
routines:ASN1_get_object:too long
at org.apache.harmony.xnet.provider.jsse.NativeCrypto.d2i_PUBKEY(Native Method)
at org.apache.harmony.xnet.provider.jsse.OpenSSLRSAKeyFactory.engineGeneratePublic(OpenSSLRSAKeyfactory.java:48)
I found that activity that started the purchase may be destroyed, what should I do in that case?
Any suggestions?

call that purchase activity using calling activity for result concept.check whether the result at onActivityResult() function using RESULT_OK and RESULT_CANCELLED so you find out.

Related

Android IAB InvalidKeySpecException

I use android IAB, It work perfectly on Nexus 5 but on asus zenfone I encounter error with following stacktracke
java.lang.IllegalArgumentException: java.security.spec.InvalidKeySpecException: java.lang.RuntimeException: error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag
at com.miskatmobile.android.almishbah.util.Security.generatePublicKey(Security.java:86)
at com.miskatmobile.android.almishbah.util.Security.verifyPurchase(Security.java:66)
at com.miskatmobile.android.almishbah.util.IabHelper.queryPurchases(IabHelper.java:773)
at com.miskatmobile.android.almishbah.util.IabHelper.queryInventory(IabHelper.java:532)
at com.miskatmobile.android.almishbah.util.IabHelper.queryInventory(IabHelper.java:510)
at com.miskatmobile.android.almishbah.util.IabHelper$2.run(IabHelper.java:589)
at java.lang.Thread.run(Thread.java:841)
Caused by: java.security.spec.InvalidKeySpecException: java.lang.RuntimeException: error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag
at 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.miskatmobile.android.almishbah.util.Security.generatePublicKey(Security.java:81)
at com.miskatmobile.android.almishbah.util.Security.verifyPurchase(Security.java:66)
at com.miskatmobile.android.almishbah.util.IabHelper.queryPurchases(IabHelper.java:773)
at com.miskatmobile.android.almishbah.util.IabHelper.queryInventory(IabHelper.java:532)
at com.miskatmobile.android.almishbah.util.IabHelper.queryInventory(IabHelper.java:510)
at com.miskatmobile.android.almishbah.util.IabHelper$2.run(IabHelper.java:589)
at java.lang.Thread.run(Thread.java:841)
Caused by: java.lang.RuntimeException: error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag
at com.android.org.conscrypt.NativeCrypto.d2i_PUBKEY(NativeCrypto.java)
at com.android.org.conscrypt.OpenSSLKey.getPublicKey(OpenSSLKey.java:99)
at com.android.org.conscrypt.OpenSSLRSAKeyFactory.engineGeneratePublic(OpenSSLRSAKeyFactory.java:47)
at java.security.KeyFactory.generatePublic(KeyFactory.java:171)
at com.miskatmobile.android.almishbah.util.Security.generatePublicKey(Security.java:81)
at com.miskatmobile.android.almishbah.util.Security.verifyPurchase(Security.java:66)
at com.miskatmobile.android.almishbah.util.IabHelper.queryPurchases(IabHelper.java:773)
at com.miskatmobile.android.almishbah.util.IabHelper.queryInventory(IabHelper.java:532)
at com.miskatmobile.android.almishbah.util.IabHelper.queryInventory(IabHelper.java:510)
at com.miskatmobile.android.almishbah.util.IabHelper$2.run(IabHelper.java:589)
at java.lang.Thread.run(Thread.java:841)
any idea why it happened?
thanks

Crash when selecting picture from gallery in phonegap

I've been reading a lot and searching on the internet and I have found similar questions but still no answer. So I will try again :)
I'm developing an app with phonegap 2.7 and I'm using the recommended function to upload pictures. The problem is that some users are reporting an exception when trying to select their pictures, and the app is crashing.
Looking at the google play console I can see this error:
java.lang.RuntimeException: Unable to resume activity
{com.xmile.events/com.xmile.events.MainActivity}: java.lang.RuntimeException: Failure
delivering result ResultInfo{who=null, request=18, result=-1, data=Intent {
dat=content://media/external/images/media/201233 }} to activity
{com.xmile.events/com.xmile.events.MainActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2444)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2472)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1986)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null,
request=18, result=-1, data=Intent { dat=content://media/external/images/media/201233 }}
to activity {com.xmile.events/com.xmile.events.MainActivity}:
java.lang.NullPointerException
at android.app.ActivityThread.deliverResults(ActivityThread.java:2980)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2431)
... 12 more
Caused by: java.lang.NullPointerException
at org.apache.cordova.DroidGap.onActivityResult(DroidGap.java:858)
at android.app.Activity.dispatchActivityResult(Activity.java:4649)
at android.app.ActivityThread.deliverResults(ActivityThread.java:2976)
... 13 more
The function to select the image is this one:
function selectPicture() {
pictureSource=navigator.camera.PictureSourceType;
destinationType=navigator.camera.DestinationType;
// Retrieve image file location from specified source
navigator.camera.getPicture(
onPhotoURISuccess, onFail, { quality: 25,
destinationType: destinationType.FILE_URI,
sourceType: pictureSource.PHOTOLIBRARY });
}
So I understand the problem arises when a user selects an image and goes back to the main process... somehow it is dead and then a NPE comes up :'( Even more weird, it only happens to a few users and I can't reproduce it with my mobile.
Any help would be highly appreciated!
I guess you are trying with Android version 4.1 or 4.2. If it's the case so refer to this answer :
Phonegap : Upload picture crashes on Samsung mobile 4.1.2 but works fine on Google Nexus 4.3.0

ActivityNotFoundException when opening the browser

sometimes my app crashes when i try to open a browser within the app for adds, here is my code:
public void onBannerClick(final View view){
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(mBannerURL));
startActivity(intent);
and this is the stacktrace i get:
java.lang.IllegalStateException: Could not execute method of the activity
at android.view.View$1.onClick(View.java:2179)
at android.view.View.performClick(View.java:2535)
at android.view.View$PerformClick.run(View.java:9130)
at android.os.Handler.handleCallback(Handler.java:618)
at android.os.Handler.dispatchMessage(Handler.java:123)
at android.os.Looper.loop(SourceFile:351)
at android.app.ActivityThread.main(ActivityThread.java:3850)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:538)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:659)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:538)
at android.view.View$1.onClick(View.java:2174)
... 11 more
Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=http://xxxxxxxxx.xx }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1449)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1419)
at android.app.Activity.startActivityForResult(Activity.java:2878)
at android.app.Activity.startActivity(Activity.java:2984)
at com.XXXXXXXXX.XXXXXXXXXXXXX.MainActivity.onBannerClick(MainActivity.java:830)
... 14 more
can any1 please help?
Check to see that you scheme is spelled correctly. I found that simply using "HTTP:" instead of "http:" caused exactly this problem. Note at the bottom of this page:
http://developer.android.com/guide/topics/manifest/data-element.html
... that scheme matching in Android is case sensitive.
Presumably either you are getting some sort of HTTP error (e.g., invalid URL and a 404 response) or the HTTP response is served under a MIME type that your device lacks an app for.
I faced the same issue after a lots of try I found the issue was with my URL.
I changed the URL to https, later its work

Classnotfound exception for working app

I have a strange issue.I developed an android application with scan functionality.I reused some zxing code code for the scanning section. My app is working fine for all the device and emulater too.But after I uploaded it in market I am getting error on scan portion.My error report is
java.lang.IllegalStateException: Could not execute method of the activity
at android.view.View$1.onClick(View.java:2191)
at android.view.View.performClick(View.java:2532)
at android.view.View$PerformClick.run(View.java:9291)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:4293)
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:849)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at android.view.View$1.onClick(View.java:2186)
... 11 more
Caused by: java.lang.ExceptionInInitializerError
at com.imotiva.Menu1.points(Menu1.java:46)
... 14 more
Caused by: java.lang.NoClassDefFoundError: com.qr.decoding.ResultMetadataType
at com.qr.scanning.CaptureActivity.<clinit>(CaptureActivity.java:92)
... 15 more
Still my code code is working in device but the same app in the market don't. Please help me friends...
At last I found the solution for my problem.gtumca-MAC's solution Android update 17 seems incompatible with external Jars worked for me.Created one folder named libs and add my core.jar .Now it's working fine.Thanks all.

SQLiteException Unknown error

Does anyone know what this means? I'm trying to start a transaction in onActivityResult() to insert a row based on the received result.
03-05 15:39:51.937:
ERROR/Database(2387): Failure 21 (out
of memory) on 0x0 when preparing
'BEGIN EXCLUSIVE;'.
03-05 15:39:51.967:
DEBUG/AndroidRuntime(2387): Shutting
down VM 03-05 15:39:51.967:
WARN/dalvikvm(2387): threadid=3:
thread exiting with uncaught exception
(group=0x40013140)
03-05 15:39:51.967:
ERROR/AndroidRuntime(2387): Uncaught
handler: thread main exiting due to
uncaught exception
03-05 15:39:52.137:
ERROR/AndroidRuntime(2387):
java.lang.RuntimeException: Failure
delivering result ResultInfo{who=null,
request=1, result=-1, data=Intent {
(has extras) }} to activity
{com.ozdroid/com.ozdroid.load.LoadView}:
android.database.sqlite.SQLiteException:
unknown error: BEGIN EXCLUSIVE;
...
03-05 15:39:52.137:
ERROR/AndroidRuntime(2387): Caused by:
android.database.sqlite.SQLiteException:
unknown error: BEGIN EXCLUSIVE;
...
03-05 15:39:52.137:
ERROR/AndroidRuntime(2387): at
android.database.sqlite.SQLiteDatabase.beginTransaction(SQLiteDatabase.java:434)
I've had this happen to me in two situations:
when SQL statements contain syntax errors
when beginTransaction is called on a not-open database connection
It looks like you've run into number two. Check your syntax and make sure you open() (and don't close()) your database before you call beginTransaction.
And I think we can agree that the resulting logcat error messages are not 100% helpful.

Categories

Resources