Android IAB InvalidKeySpecException - android

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

Related

NoClassDefFound when using MimeMessage.setText(), for Gmail API in android

Following the example provided here:
https://developers.google.com/gmail/api/v1/reference/users/messages/send#examples
email.setText() throws a NoClassDefFoundException:
Process: com.slickapp.www.slicklikeapp, PID: 19125
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:309)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.NoClassDefFoundError: javax.activation.DataHandler
at javax.mail.internet.MimeMessage.setContent(MimeMessage.java:1428)
at javax.mail.internet.MimeBodyPart.setText(MimeBodyPart.java:1029)
at javax.mail.internet.MimeMessage.setText(MimeMessage.java:1467)
at javax.mail.internet.MimeMessage.setText(MimeMessage.java:1451)
at com.slickapp.www.slicklikeapp.ComposeEmailActivity$SendEmailTask.doInBackground(ComposeEmailActivity.java:153)
at com.slickapp.www.slicklikeapp.ComposeEmailActivity$SendEmailTask.doInBackground(ComposeEmailActivity.java:113)
at android.os.AsyncTask$2.call(AsyncTask.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Finding solutions in the following links:
java.lang.NoClassDefFoundError: javax.activation.DataHandler
java.lang.NoClassDefFoundError: javax.activation.DataHandler in android
I understand that this exception is due to android not implementing java.awt.datatransfer classes. I tried the solutions but they didnt work. When i added javax.mail 1.5.5 in gradle it shows a duplicate file copied error.
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/mimetypes.default
File1: C:\Users\Taha\.gradle\caches\modules-2\files-2.1\com.sun.mail\android-activation\1.5.6\34c941857c08ff1d6af9a43a8806342883b2a8e1\android-activation-1.5.6.jar
File2: C:\Users\Taha\.gradle\caches\modules-2\files-2.1\javax.activation\activation\1.1\e6cb541461c2834bdea3eb920f1884d1eb508b50\activation-1.1.jar
I couldnt find any solutions for this. I tried excluding excluding file in gradle packaging options, it didnt work only throwing NoClassDefFound exception again.
Any help would be appreciated.

Android NoSuchMethodException: callDrawGLFunction

I find the method is reanme to callDrawGLFunction2 at the android version of 5.1.0 . And add the class of com.android.webview.chromium.WebViewDelegateFactory at the same time.
But i don't know how to fix the bug. can anyone have idea.
full stack:
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
... 25 more
Caused by: android.util.AndroidRuntimeException: java.lang.RuntimeException: Invalid reflection
at android.webkit.WebViewFactory.getProvider(WebViewFactory.java)
at android.webkit.WebView.getFactory(WebView.java)
at android.webkit.WebView.ensureProviderCreated(WebView.java)
at android.webkit.WebView.setOverScrollMode(WebView.java)
at android.view.View.init(View.java)
at android.view.View.init(View.java)
at android.view.ViewGroup.init(ViewGroup.java)
at android.widget.AbsoluteLayout.init(AbsoluteLayout.java)
at android.webkit.WebView.init(WebView.java)
at android.webkit.WebView.init(WebView.java)
at android.webkit.WebView.init(WebView.java)
at android.webkit.WebView.init(WebView.java)
... 27 more
Caused by: java.lang.RuntimeException: Invalid reflection
at com.android.webview.chromium.WebViewDelegateFactory$Api21CompatibilityDelegate.init(WebViewDelegateFactory.java:258)
at com.android.webview.chromium.WebViewChromiumFactoryProvider.init(WebViewChromiumFactoryProvider.java:2106)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.Class.newInstance(Class.java:1690)
... 39 more
Caused by: java.lang.NoSuchMethodException: callDrawGLFunction [long]
at java.lang.Class.getMethod(Class.java:671)
at com.android.webview.chromium.WebViewDelegateFactory$Api21CompatibilityDelegate.init(WebViewDelegateFactory.java:246)
... 42 more
android.view.InflateException: Binary XML file line #21: Error inflating class android.webkit.WebView
at android.view.LayoutInflater.createView(LayoutInflater.java)
It's not application error.
The bug is all report from the device of sdk 22. But the method is already rename in that version.
I send email to google developer who rename the method from callDrawGLFunction to callDrawGLFunction2. I got some reply:
"Api21CompatibilityDelegate means webview believes it's running on 21. Renaming callDrawGLFunction happened after API21, hence webview is trying look for the old name."
So It's obvious device rom bug.

cmusphinx in android-java.lang.RuntimeException: Decoder_setKeyphrase returned -1

I am using cmusphinx in android. First of all i executed demo project downloaded from Github. When i built my own dictionary created own keyPhrase it gives the following execption
FATAL EXCEPTION: AsyncTask #1
Process: edu.cmu.sphinx.pocketsphinx, PID: 5006
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: java.lang.RuntimeException: Decoder_setKeyphrase returned -1
at edu.cmu.pocketsphinx.PocketSphinxJNI.Decoder_setKeyphrase(Native Method)
at edu.cmu.pocketsphinx.Decoder.setKeyphrase(Decoder.java:155)
at edu.cmu.pocketsphinx.SpeechRecognizer.addKeyphraseSearch(SpeechRecognizer.java:259)
at edu.cmu.pocketsphinx.demo.PocketSphinxActivity.setupRecognizer(PocketSphinxActivity.java:203)
at edu.cmu.pocketsphinx.demo.PocketSphinxActivity.access$000(PocketSphinxActivity.java:51)
at edu.cmu.pocketsphinx.demo.PocketSphinxActivity$1.doInBackground(PocketSphinxActivity.java:91)
at edu.cmu.pocketsphinx.demo.PocketSphinxActivity$1.doInBackground(PocketSphinxActivity.java:85)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
at java.lang.Thread.run(Thread.java:841) 
here is my contents of cmudict-en-us.dict
HELLO HH AH L OW
HELLO(2) HH EH L OW
HIMANSHU HH AH M AE N SH UW
and i set my keyphrase as
private static final String KEYPHRASE = "hello himanshu";
Words are case-sensitive. Your keyphrase must be in uppercase as in the dictionary. Or words in the dictionary must be lowercase. Phonemes must be in uppercase.
To debug errors like this you can read logcat output, it provides detailed messages about the problem.

String length errors with an Android Content Provider Authority string

The original name of the content provider authority that works fine with no errors:
public static final String AUTHORITY = com.dakotastream.cardiologger.CardioLoggerProvider12;
I want rename my authority to:
public static final String AUTHORITY = com.dakotastream.cardiologger.CardioLoggerProvider;
When I change the name to the above I get this error.
Caused by: java.lang.StringIndexOutOfBoundsException: length=68; index=70
public static final String AUTHORITY = com.dakotastream.cardiologger.CardioLoggerProvider1;
When I change the name to the above I get this error.
Caused by: java.lang.StringIndexOutOfBoundsException: length=69; index=70
If I rename the package to com.dakotastream.cardiologger12, then I can use the
public static final String AUTHORITY = com.dakotastream.cardiologger12.CardioLoggerProvider;
with no errors.
The Authority seems to require a string length greater than 69 characters.
I am using SDK Tools 22.6.3, API 19, ABS Library 4.4.0
I have tried creating a new Android Application Project and dropping the code in. I get the same error.
Entire LogCat Dump:
FATAL EXCEPTION: ModernAsyncTask #1
Process: com.dakotastream.cardiologger, PID: 1344
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.support.v4.content.ModernAsyncTask$3.done(ModernAsyncTask.java:137)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: java.lang.StringIndexOutOfBoundsException: length=68; index=70
at java.lang.String.indexAndLength(String.java:584)
at java.lang.String.substring(String.java:1449)
at com.dakotastream.cardiologger.DbContentProvider.query(DbContentProvider.java:279)
at android.content.ContentProvider.query(ContentProvider.java:857)
at android.content.ContentProvider$Transport.query(ContentProvider.java:200)
at android.content.ContentResolver.query(ContentResolver.java:461)
at android.content.ContentResolver.query(ContentResolver.java:404)
at android.support.v4.content.CursorLoader.loadInBackground(CursorLoader.java:49)
at android.support.v4.content.CursorLoader.loadInBackground(CursorLoader.java:35)
at android.support.v4.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:242)
at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:51)
at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:40)
at android.support.v4.content.ModernAsyncTask$2.call(ModernAsyncTask.java:123)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
In Eclipse I use Android Tools>Rename Application Package to change the name.
This is the error I get when I change the name.
Update the android:authorities tag accordingly for the provider in the manifest.

Android in-app purchase flow broken

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.

Categories

Resources