Crash when selecting picture from gallery in phonegap - android

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

Related

Firebase Authentication causing Android fatal exception

I just finished integrating Firebase real time data base and Authentication into my Android Studio application. It ran successfully two or three times on my Google Nexus 7 genymotion emulator that has google play services on it. Then I tried launching it again and I started getting the below error:
06-25 16:50:46.994 7699-7699/
com.careersvirtualsolutions.uprate E/AndroidRuntime:
FATAL EXCEPTION: main
java.lang.NullPointerException
at com.google.firebase.auth.FirebaseAuth$1.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
I think this has something to do with the Firebase Authentication SDK but I am not sure.
Do you know what this is caused by? How can I solve it?
I actually figured it out, the problem was with the AuthStateListener.
So if you're having a similar issue, try testing your project with the AuthStateListener commented out and see if it launches without crashing. If it does you can then figure out how to replace the existing listener.
Hope this helps in some way!

Android Live Wallpaper crashes on Amazon App Store Testing ActivityNotFoundException

I am trying to put my live wallpaper on Amazon App Store(This live wallpaper is already live on Google Play Store), However, when I uploaded same APK for testing on Amazon Developer site it reports following exception
03-06 06:00:50.741 7598 7598 E AndroidRuntime: FATAL EXCEPTION: main
03-06 06:00:50.741 7598 7598 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.rrapps.heavensdoor/com.rrapps.heavensdoor.PreviewActivity}: android.content.ActivityNotFoundException: No Activity found to handle act=android.service.wallpaper.CHANGE_LIVE_WALLPAPER (has extras)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2229)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2283)
at android.app.ActivityThread.access$600(ActivityThread.java:148)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1244)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:151)
at android.app.ActivityThread.main(ActivityThread.java:5204)
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:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.ActivityNotFoundException: No Activity found to handle act=android.service.wallpaper.CHANGE_LIVE_WALLPAPER (has extras)
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1627)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)
at android.app.Activity.startActivityForResult(Activity.java:3424)
at android.app.Activity.startActivityForResult(Activity.java:3385)
at com.rrapps.heavensdoor.PreviewActivity.onCreate(Unknown Source)
at android.app.Activity.performCreate(Activity.java:5170)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2182)
following is code where I am setting wallpaper
if (Build.VERSION.SDK_INT >= 16) {
/*
* Open live wallpaper preview (API Level 16 or greater).
*/
intent.setAction(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER);
String pkg = MyWallpaperService.class.getPackage().getName();
String cls = MyWallpaperService.class.getCanonicalName();
intent.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT,
new ComponentName(pkg, cls));
} else {
/*
* Open live wallpaper picker (API Level 15 or lower).
*
* Display a quick little message (toast) with instructions.
*/
intent.setAction(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER);
Resources res = getResources();
String hint = res.getString(R.string.picker_toast_prefix)
+ res.getString(R.string.lwp_name)
+ res.getString(R.string.picker_toast_suffix);
Toast toast = Toast.makeText(this, hint, Toast.LENGTH_LONG);
toast.show();
}
startActivityForResult(intent, 0);
I am not sure what the problem is. Any help is appreciated.
Android is a funny world and implicit intents unfortunately, vary more than we (developers) would like them to. Specially for Amazon devices, that are not required to comply with Google test suite. On my app, I've seen ActivityNotFoundException trying to launch the web-browser.
So my suggestion, even tho it doesn't actually fix the issue, it's just try catch it:
try{
startActivityForResult(intent, 0);
} catch(ActivityNotFoundException e) {
// why amazon, why?
}

First time Google Map API

I am a first time Android Studio user, trying to get the Google Map app to run from the samples provided. Android-Studio is running on a Gentoo Linux platform, using Java 8. I have followed the directions on how to add Google Play services, added the definition to Gradle, far as I can tell it is the virtual device that does not have Google play service support. I have also added pro-guard rules, error is always the same. The build rules and dependencies have the entries from the documentation. It looks like it should work.
It is obvious that I am missing something basic. The basic HelloWorld works fine, I am stumbling on Google's security and the mechanism by which they are invoked. Reviewing the documentation, I see references to GoogleAPIClient -- Do I have to setup the client connection before trying to connect? Is there, perhaps sample code where this process is defined correctly, with all its pieces?
The studio itself is at current revision levels. From the error, is it possible I have missed something else, the ActivityNotFound exception?
The LogCat message stream
09-10 10:07:16.449 1006-1006/cx.ath.klatt.test1 E/AndroidRuntime﹕ FATAL EXCEPTION: main
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=market://details?id=com.google.android.gms flg=0x80000 pkg=com.android.vending }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1622)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)
at android.app.Activity.startActivityForResult(Activity.java:3370)
at android.app.Activity.startActivityForResult(Activity.java:3331)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:840)
at android.app.Activity.startActivity(Activity.java:3566)
at android.app.Activity.startActivity(Activity.java:3534)
at com.google.android.gms.dynamic.a$5.onClick(Unknown Source)
at android.view.View.performClick(View.java:4204)
at android.view.View$PerformClick.run(View.java:17355)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
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:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
09-10 10:07:18.929 1006-1006/cx.ath.klatt.test1 I/Process﹕ Sending signal. PID: 1006 SIG: 9
09-10 10:07:47.989 1035-1035/cx.ath.klatt.test1 W/GooglePlayServicesUtil﹕ Google Play services is missing.
The device in which you are installing, the google play services need to be installed and need to be up to date also.

Facebook Unity Sdk v5.0.3 crashes in Landscape mode when trying to login - Android

The game crashes when I click at login button as the game is in landscape mode. If I use portrait mode, everything works fine and correctly.
I got the following stack trace from bugsense when I got the crash.
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.adssdk.plugins/com.facebook.unity.FBUnityLoginActivity}: java.lang.UnsupportedOperationException: Session: an attempt was made to request new permissions for a session that has a pending request.
1at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2205)
2at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2240)
3at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3809)
4at android.app.ActivityThread.access$700(ActivityThread.java:139)
5at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1266)
6at android.os.Handler.dispatchMessage(Handler.java:99)
7at android.os.Looper.loop(Looper.java:156)
8at android.app.ActivityThread.main(ActivityThread.java:4987)
9at java.lang.reflect.Method.invokeNative(Native Method)
10at java.lang.reflect.Method.invoke(Method.java:511)
11at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
12at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
13at dalvik.system.NativeStart.main(Native Method)
14Caused by: java.lang.UnsupportedOperationException: Session: an attempt was made to request new permissions for a session that has a pending request.
15at com.facebook.Session.requestNewPermissions(Session.java:1006)
16at com.facebook.Session.requestNewPublishPermissions(Session.java:512)
17at com.facebook.unity.FB.initAndLogin(FB.java:200)
18at com.facebook.unity.FB.LoginUsingActivity(FB.java:249)
19at com.facebook.unity.FBUnityLoginActivity.onCreate(FBUnityLoginActivity.java:13)
20at android.app.Activity.performCreate(Activity.java:4538)
21at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1071)
22at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
If anyone of you has implemented this in landscape mode and is not getting a crash while logging in, do let me know.
yes, this is a bug, we are working on proper fix right now.
Meanwhile you can edit your android manifest in Plugins/Android and add android:configChanges so that FBUnityLoginActivity isn't destroyed when orientation/whatever changes:
<activity
android:name="com.facebook.unity.FBUnityLoginActivity"
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen">
</activity>
you may also want to remove "Translucent" from activity style.
I confirm that the change in the manifest file fixed the crash for me also. As additional info: the location of manifest the file was in Assets\Plugins\Android and the name was AndroidManifest.xml. I tested the fix on Sony Xperia M.

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