[Aerogear-users] An app crash scenario after clicking on push notification

Federico Cerminara fedecentrico at gmail.com
Fri Apr 28 05:56:24 EDT 2017


Hi Summers,
following your notes, I found some tutorials about hot to modify a plugin
Java source code (and, againg, I'd like to thank you for this). Comparing
them, I thought the best approach was to remove the plugin and after add it
again (specifying this time in the “cordova plugin add” command a folder in
my filesystem containing the plugin) after having modified the source code
related to the bug fix.

Using aerogear cordova plugin forces me to do something similar trying to
generate apk/ipa using Intel XDK environment because the build process does
not like a reference to src/android/dependencies.gradle in plugin.xml file
(so I have the remove the plugin, download it locally, hide the reference,
then add the plugin again by specifying a local folder in Intel XDK
interface).

The first question is: can I use my "new/modified" plugin “easily” or
should I worry about some license violations?  If you have suggested me to
try myself to modify plugin behavior in order to fix the null pointer
exception problem, can I presume I can use the plugin even after making it
different from your baseline version?

Second point. I’m gonna describe the changes I’ve applied to the Java code,
which are quite similar to what you told me with those links. It seems now
the plugin works correctly but we'll continue to test it to be sure. May
you confirm however this could be the right solution?

In *PushHandlerActivity.java* I modified the following source line:

*Store<Message> store = DataManager.getStore("messageStore");*

with these:






*SQLStore<Message> store =
(SQLStore<Message>)DataManager.getStore("messageStore");if (store == null)
{    store = (SQLStore<Message>) DataManager.config("messageStore",
SQLStoreConfiguration.class).withContext(this.getApplicationContext()).store(Message.class);
store.openSync();}    *
As you can see, I changed the store type from Store<Message> to
SQLStore<Message> to alline it with the source code in
NotificationMessageHandler.java. Moreover, because I needed a context
object, I resolved the context by invoking *this.getApplicationContext()*
(such it was an activity class). Just for completeness, I introduced the
needed imports in the right section for SQLStore and SQLStoreConfiguration.
To avoid some other null pointer exception troubles, I added another not
null check before cycling the message collection. Now the cycle starts if
and only if collection is not null.

*if(collection!=null){    for (Message message : collection){ ... .... }
}    *

Do you think there’s something wrong or something I’ve not evaluated
applying these changes? As usually, and before closing this mail, I’d like
to thank you again: your help has been important to facilitate us some
precious steps. Thanks so for all your support.

Just a last thing. Let's image all these changes are correct; in some of
your last messages you told me to send eventually a pull request. How can I
do it? This should be really all.

Federico


2017-04-21 8:37 GMT+02:00 Federico Cerminara <fedecentrico at gmail.com>:

> Summers,
> I'd like to thank you for all your important support.
> I'm gonna have a look at Cordova developer docs.
> Eventually I'll try to write you again if there are some specific question
> about the bug fix.
> Have a nice day and thanks again for everything.
> Federico
>
>
> 2017-04-20 17:43 GMT+02:00 Summers Pittman <supittma at redhat.com>:
>
>>
>>
>> On Thu, Apr 20, 2017 at 10:42 AM, Federico Cerminara <
>> fedecentrico at gmail.com> wrote:
>>
>>> Hi Summers,
>>> even if I am not the bravest developer I know, the main trouble is the
>>> lack of time available to spend on this job. Before deciding internally how
>>> to face the problem, I'd like to ask you if you've already scheduled a
>>> fixing activity for this bug in a future release (and eventually which
>>> could be a date to have an official fix).
>>> Instead, if you think the better approach is to trust on my bravery, I'm
>>> here to ask you how I could recompile the plugin after applyng all the
>>> modifies it requires. What can you suggest me to do? Wait anyway for a
>>> future release or start testing a solution and after sending a pull
>>> request?
>>>
>>>
>> Well it isn't my project so I can't make any timeline commitments.
>> However if you send a pull request it makes it easier to bundle a release.
>>
>> I suggest you read the Cordova developer docs to learn how to write a
>> plugin, they teach you how to compile it for the various platforms as well.
>>
>>
>>> Thanks anyway, Federico.
>>>
>>>
>>>
>>>
>>> 2017-04-20 15:24 GMT+02:00 Summers Pittman <supittma at redhat.com>:
>>>
>>>>
>>>>
>>>> On Thu, Apr 20, 2017 at 6:08 AM, Federico Cerminara <
>>>> fedecentrico at gmail.com> wrote:
>>>>
>>>>> Hi Summers,
>>>>> first of all, i'd like to thank you for your precious suggestion.
>>>>> I managed to launch my app using Android Emulator and together with
>>>>> the logcat tool.
>>>>> Thanks to this new approach, i was able to take some lines from the
>>>>> logcat stacktrace and now i can share them in the following.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> *04-20 11:35:44.861 31658 31658 E AndroidRuntime:
>>>>> java.lang.RuntimeException: Unable to start activity
>>>>> ComponentInfo{org.jboss.aerogear.android.cookbook.aerodoc/org.jboss.aerogear.cordova.push.PushHandlerActivity}:
>>>>> java.lang.NullPointerException: Attempt to invoke interface method
>>>>> 'java.util.Collection org.jboss.aerogear.android.store.Store.readAll()' on
>>>>> a null object reference... ... ... 04-20 11:35:44.861 31658 31658 E
>>>>> AndroidRuntime: Caused by: java.lang.NullPointerException: Attempt to
>>>>> invoke interface method 'java.util.Collection
>>>>> org.jboss.aerogear.android.store.Store.readAll()' on a null object
>>>>> reference04-20 11:35:44.861 31658 31658 E AndroidRuntime:     at
>>>>> org.jboss.aerogear.cordova.push.PushHandlerActivity.processPushBundle(PushHandlerActivity.java:60)04-20
>>>>> 11:35:44.861 31658 31658 E AndroidRuntime:     at
>>>>> org.jboss.aerogear.cordova.push.PushHandlerActivity.onCreate(PushHandlerActivity.java:45)04-20
>>>>> 11:35:44.861 31658 31658 E AndroidRuntime:     at
>>>>> android.app.Activity.performCreate(Activity.java:6876)04-20 11:35:44.861
>>>>> 31658 31658 E AndroidRuntime:     at android.app.Instrumentation.ca
>>>>> <http://android.app.Instrumentation.ca>llActivityOnCreate(Instrumentation.java:1135)04-20
>>>>> 11:35:44.861 31658 31658 E AndroidRuntime:     at
>>>>> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3207)04-20
>>>>> 11:35:44.861 31658 31658 E AndroidRuntime:     ... 9 more*
>>>>> As i wrote in the first mail, this is the app crash scenario. If I
>>>>> have my app closed or already open, clicking on push notification seems to
>>>>> behave correctly, bringing user to application first page. Instead, if I
>>>>> try to close all my applications after receiving one or more push
>>>>> notification (image notification frequency is quite low) and then I try to
>>>>> click on my waiting push, application crashes showing a message that sound
>>>>> quite like this “The program <app_name> has been interrupted”
>>>>>
>>>>> Reading the log stacktrace, it seems like there's a NPE in
>>>>> *PushHandlerActivity.java:60*, and more precisely when it tries to
>>>>> read the store content.
>>>>> Now, I don't know if it's the right place to face the problem, of if I
>>>>> should open a ticket somewhere else, or if it's an already known and solved
>>>>> bug, or if eventually it's some kind of problem related to a wrong
>>>>> configuration in my app. Before losing me in all this wondering, can you
>>>>> suggest me what to do? Could i try directly to change the java code in the
>>>>> class PushHandlerActivity? Should it have effect, also eventually to make a
>>>>> test locally?
>>>>>
>>>>>
>>>> So 1) I think we have this bug known already (
>>>> https://issues.jboss.org/browse/AGCORDOVA-167), sorry about that.
>>>>
>>>> 2) If you are feeling brave you can add the null/initialization check
>>>> from here :
>>>>
>>>>    https://github.com/aerogear/aerogear-cordova-push/blob/b313
>>>> fcfb20708089f2e0bcb871e396f67ee2b1a5/src/android/org/jboss/a
>>>> erogear/cordova/push/NotificationMessageHandler.java#L43
>>>>
>>>> to here :
>>>>
>>>>   https://github.com/aerogear/aerogear-cordova-push/blob/b31
>>>> 3fcfb20708089f2e0bcb871e396f67ee2b1a5/src/android/org/jboss/
>>>> aerogear/cordova/push/PushHandlerActivity.java#L60
>>>>
>>>> rebuild the cordova library, test it, and send a pull request if it
>>>> fixes your problem.
>>>>
>>>>
>>>>> Here some information about my test conditions which could be useful.
>>>>>
>>>>> OS: Android 6.0.1
>>>>> Device: Samsung S6
>>>>> Aerogear Plugin Version: 3.1.0
>>>>>
>>>>> We're talking about a cross platform application developed with Ionic
>>>>> 1 and Angular 1.
>>>>> I did not try to verify if the problem is happening also on a iOS
>>>>> device, but i'm gonna do it immediately after writing this reply.
>>>>> Do you think some other info could be useful?
>>>>>
>>>>> Thanks anyway, Federico.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> 2017-04-19 13:37 GMT+02:00 Summers Pittman <supittma at redhat.com>:
>>>>>
>>>>>> The easiest tool to use is logcat with the Android emulator.  Logcat
>>>>>> is part of the Android SDK which you installed while you were setting up
>>>>>> your development environment (it may have been installed by another tool
>>>>>> but it is there).
>>>>>>
>>>>>> All you need to do is, from the command line, run logcat.  Then run
>>>>>> your application and wait for it to crash, and you will find the stack
>>>>>> trace (and a bunch of other stuff), in the log.  It is possible to filter
>>>>>> the logcat output based on the package name of the application generating
>>>>>> logs, but one thing at a time.
>>>>>>
>>>>>> Summers
>>>>>>
>>>>>> On Wed, Apr 19, 2017 at 4:11 AM, Federico Cerminara <
>>>>>> fedecentrico at gmail.com> wrote:
>>>>>>
>>>>>>> Still not able to introduce a tool to produce a stacktrace. I know
>>>>>>> it would be helpful (if you have suggestions about which
>>>>>>> tool/plugin/approach to use...) but now i am still not able to do it. I’m
>>>>>>> a beginner in cross platform app development, as i said before :(
>>>>>>>
>>>>>>> 2017-04-18 17:23 GMT+02:00 Summers Pittman <supittma at redhat.com>:
>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Tue, Apr 18, 2017 at 10:55 AM, Federico Cerminara <
>>>>>>>> fedecentrico at gmail.com> wrote:
>>>>>>>>
>>>>>>>>> Hi Summers,
>>>>>>>>> thanks for your immediate reply. The OS on the device i am testing
>>>>>>>>> now is Android 6.0.1, but I don't know if it's an useful information cause
>>>>>>>>> I'm using Ionic 1 and Angular 1 to develop a Cross Platform App.
>>>>>>>>>
>>>>>>>>> The code is not publicly available but I can share some code
>>>>>>>>> pieces if you suggest me which pieces of code could help us for this
>>>>>>>>> analysis.
>>>>>>>>>
>>>>>>>>> It's not ax example app, I just took inspiration from the snippet
>>>>>>>>> of code included in Android aerogear variant and used them to complete my
>>>>>>>>> app.js code.
>>>>>>>>>
>>>>>>>>> How could you help me?
>>>>>>>>>
>>>>>>>>
>>>>>>>> Would you be able to include your stack trace from logcat when the
>>>>>>>> application crashes?
>>>>>>>>
>>>>>>>> I'm not as familiar with Cordova as I should be, but I should be
>>>>>>>> able to make heads or tails of it.
>>>>>>>>
>>>>>>>>
>>>>>>>>> Thanks anyway, Federico.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> 2017-04-18 16:33 GMT+02:00 Summers Pittman <supittma at redhat.com>:
>>>>>>>>>
>>>>>>>>>> Frederico,
>>>>>>>>>>
>>>>>>>>>> Hi, sorry you are having trouble with UPS.  If you could help us
>>>>>>>>>> out by answering a couple of questions that would be great.
>>>>>>>>>>
>>>>>>>>>> 1) Which OS is your applicatoin having trouble on and are you
>>>>>>>>>> using Cordova or native libraries?
>>>>>>>>>>
>>>>>>>>>> 2) Is your code publicly available somewhere for us to look at?
>>>>>>>>>>
>>>>>>>>>> 3) Are you using the example app or is this your own
>>>>>>>>>> implementation?
>>>>>>>>>>
>>>>>>>>>> I know from experience that with Android one of the common
>>>>>>>>>> problems is that if the application has been killed by the OS then the Push
>>>>>>>>>> libraries have to be reinitialized before you can send metrics to the
>>>>>>>>>> server.  If you are initializing your push libraries in an Activity class
>>>>>>>>>> instead of the Application class this may be something to double check.  Of
>>>>>>>>>> course if this is iOS or Cordova then everything I just said is nonsense :)
>>>>>>>>>>
>>>>>>>>>> Summers
>>>>>>>>>>
>>>>>>>>>> On Tue, Apr 18, 2017 at 10:18 AM, Federico Cerminara <
>>>>>>>>>> fedecentrico at gmail.com> wrote:
>>>>>>>>>>
>>>>>>>>>>> Hi,
>>>>>>>>>>> my name is Federico Cerminara, 35 years old, engineer and web
>>>>>>>>>>> developer in Rome.
>>>>>>>>>>> I’m a beginner in cross platform app development and I’ve
>>>>>>>>>>> started using aerogear cordova push plugin to enable reception of push
>>>>>>>>>>> notification.
>>>>>>>>>>>
>>>>>>>>>>> I’ve developed my first app. I’m able to receive correctly push
>>>>>>>>>>> notification, both sending them directly by aerogear admin panel after
>>>>>>>>>>> choosing a variant and and sending them from the application backend
>>>>>>>>>>> following a custom logic. If I have my app closed or already open, clicking
>>>>>>>>>>> on push notification seems to behave correctly, bringing user to
>>>>>>>>>>> application first page. Instead, if I try to close all my applications
>>>>>>>>>>> after receiving one or more push notification (image notification frequency
>>>>>>>>>>> is quite low) and then I try to click on my waiting push, application
>>>>>>>>>>> crashes showing a message that sound quite like this “The program
>>>>>>>>>>> <app_name> has been interrupted”
>>>>>>>>>>>
>>>>>>>>>>> Can you tell me a way to solve this problem?
>>>>>>>>>>> Thanks anyway, Federico.
>>>>>>>>>>>
>>>>>>>>>>> _______________________________________________
>>>>>>>>>>> Aerogear-users mailing list
>>>>>>>>>>> Aerogear-users at lists.jboss.org
>>>>>>>>>>> https://lists.jboss.org/mailman/listinfo/aerogear-users
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>
>>>


-- 
Puoi trovarmi qui, se vuoi:
facebook <http://www.facebook.com/fedecentrico>, flickr
<http://www.flickr.com/photos/fedecentrico>, linkedin
<http://it.linkedin.com/in/fedecentrico>, twitter
<http://twitter.com/fedecentrico>, anobii
<http://www.anobii.com/fedecentrico/books>
Link consigliati: Piccoli Maestri <http://www.piccolimaestri.org>, Il clima
di Cipro <http://www.facebook.com/#%21/IlClimaDiCipro>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/aerogear-users/attachments/20170428/5924a46e/attachment-0001.html 


More information about the Aerogear-users mailing list