Skip to content
This repository has been archived by the owner on Oct 20, 2021. It is now read-only.

Cannot read property 'getIntExtra' of null #46

Closed
wants to merge 2 commits into from

Conversation

RoyiNamir
Copy link

Ok. I've uploaded an app to google play store and in the pre tests , I got an error :

FATAL EXCEPTION: main
Process: org.royinamir.playwithpinky, PID: 12219
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=4590, result=0, data=null} to activity {org.royinamir.playwithpinky/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: 
Calling js method onActivityResult failed
TypeError: Cannot read property 'getIntExtra' of null
File: "file:///data/data/org.royinamir.playwithpinky/files/app/vendor.js, line: 1, column: 410904
StackTrace: 
	Frame: function:'', file:'file:///data/data/org.royinamir.playwithpinky/files/app/vendor.js', line: 1, column: 410905
	Frame: function:'e.notify', file:'file:///data/data/org.royinamir.playwithpinky/files/app/vendor.js', line: 1, column: 445959
	Frame: function:'e.onActivityResult', file:'file:///data/data/org.royinamir.playwithpinky/files/app/vendor.js', line: 1, column: 376149
	Frame: function:'r.onActivityResult', file:'file:///data/data/org.royinamir.playwithpinky/files/app/vendor.js', line: 1, column: 1084595
	at android.app.ActivityThread.deliverResults(ActivityThread.java:4750)
	at android.app.ActivityThread.handleSendResult(ActivityThread.java:4793)
	at android.app.ActivityThread.access$1500(ActivityThread.java:218)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1783)
	at android.os.Handler.dispatchMessage(Handler.java:102)
	at android.os.Looper.loop(Looper.java:145)
	at android.app.ActivityThread.main(ActivityThread.java:6934)
	at java.lang.reflect.Method.invoke(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:372)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Caused by: com.tns.NativeScriptException: 
Calling js method onActivityResult failed
TypeError: Cannot read property 'getIntExtra' of null
File: "file:///data/data/org.royinamir.playwithpinky/files/app/vendor.js, line: 1, column: 410904
StackTrace: 
	Frame: function:'', file:'file:///data/data/org.royinamir.playwithpinky/files/app/vendor.js', line: 1, column: 410905
	Frame: function:'e.notify', file:'file:///data/data/org.royinamir.playwithpinky/files/app/vendor.js', line: 1, column: 445959
	Frame: function:'e.onActivityResult', file:'file:///data/data/org.royinamir.playwithpinky/files/app/vendor.js', line: 1, column: 376149
	Frame: function:'r.onActivityResult', file:'file:///data/data/org.royinamir.playwithpinky/files/app/vendor.js', line: 1, column: 1084595
	at com.tns.Runtime.callJSMethodNative(Native Method)
	at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1101)
	at com.tns.Runtime.callJSMethodImpl(Runtime.java:983)
	at com.tns.Runtime.callJSMethod(Runtime.java:970)
	at com.tns.Runtime.callJSMethod(Runtime.java:954)
	at com.tns.Runtime.callJSMethod(Runtime.java:946)
	at com.tns.NativeScriptActivity.onActivityResult(NativeScriptActivity.java:80)
	at android.app.Activity.dispatchActivityResult(Activity.java:6867)
	at android.app.ActivityThread.deliverResults(ActivityThread.java:4746)
	... 10 more
Error reporting crash
java.lang.SecurityException: Calling from not trusted UID!
	at android.os.Parcel.readException(Parcel.java:1546)
	at android.os.Parcel.readException(Parcel.java:1499)
	at android.app.ActivityManagerProxy.handleApplicationCrash(ActivityManagerNative.java:5193)
	at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:95)
	at com.tns.NativeScriptUncaughtExceptionHandler.uncaughtException(NativeScriptUncaughtExceptionHandler.java:64)
	at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
	at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
	at android.support.test.runner.MonitoringInstrumentation$3.uncaughtException(MonitoringInstrumentation.java:8)

searched who activate this method :

image

Finding the method and the line :

image

led me to the plugin code :

image

for some reason this :

var intent = args.intent; is null on some callbacks.

Copy link
Author

@RoyiNamir RoyiNamir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

travis space

@PeterStaev
Copy link
Owner

Hey @RoyiNamir , thanks for this, but i want a bit more info when does this happen, before I merge this. In my tests i have never received the intent to be null. Are you sure you followed the set up in the tutorials? Also in what cases did you get the intent to be null?

I do not want to merge this and "mask" a possible user error.

@RoyiNamir
Copy link
Author

@PeterStaev Sure I will give you full details. Just bare with me :

This is the EXACT code I'm using in my app :
https://gist.github.com/RoyiNamir/82d6ad32cca946a4c84bd53a3c51f974

It's a service ( like i've posted here before , of all API promisified).

And this is how I consume it : https://gist.github.com/RoyiNamir/a0033d1438fb306b10956eeae502b36a

Please notice that test failed only in a certain device from google tests :

image

Where my version was 15.

And this is the exact error I provided :
image

On an earlier version , it happened in another device :

image

Now i'm at version 16 ,after the fix :

image

BTW , it's not that I've changed the flow. Programatically speaking , a property can be null. and if it can be null , we should see how we deal with it.

I don't know why activity was null
I can think of some thoughts:

The code doesn't clean the purchas.on method callback.
Also , the user might have been minimizing the app while callback was running . , and you don't check if activity exists on callback. this is the exact PR I did in eddy's code , to check activity on callback :

EddyVerbruggen/nativescript-admob@f0487b3

@PeterStaev
Copy link
Owner

Ok, after further search, seems it is a random error from Google. It does not relate to activity whatsoever since the code does not use the activity. after the purchase has been made and the intent data is what Google returns from purchase. So probably more like a problem contacting the Google services.

I will see to add your code, but will rewrite it since I don't like the multiple checks for the intent.

@RoyiNamir
Copy link
Author

  • yeah I meant intent ( not activity) :/ sorry.

PeterStaev added a commit that referenced this pull request Jun 16, 2018
@PeterStaev
Copy link
Owner

Changes have been added with c2a8b22

@PeterStaev PeterStaev closed this Jun 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants