Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26751] Hyperloop Android: Cannot read property 'apiName' null upon calling callback

GitHub Issuen/a
TypeBug
Priorityn/a
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsn/a
ReporterPrashant Saini
AssigneeEric Merriman
Created2018-12-16T15:55:44.000+0000
Updated2019-01-19T14:34:35.000+0000

Description

While using a third-party [Android Calendar](https://github.com/psinetron/slycalendarview) library with *Hyperloop* for date-range selection, we are getting a crash error as below. {noformat} [ERROR] : TiExceptionHandler: (main) [6808,6808] /hyperloop/ru.slybeaver.slycalendarview.SlyCalendarDialog$Callback.js:32 [ERROR] : TiExceptionHandler: if (arg.apiName && arg.isNativeProxy && arg.isInstanceProxy) { // Assume hyperloop proxy, wrap in JS wrapper [ERROR] : TiExceptionHandler: ^ [ERROR] : TiExceptionHandler: TypeError: Cannot read property 'apiName' of null [ERROR] : TiExceptionHandler: at _wrapArg (/hyperloop/ru.slybeaver.slycalendarview.SlyCalendarDialog$Callback.js:32:12) [ERROR] : TiExceptionHandler: at Instance._wrapArgs (/hyperloop/ru.slybeaver.slycalendarview.SlyCalendarDialog$Callback.js:42:18) [ERROR] : TiExceptionHandler: at Instance.modified.(anonymous function) (/hyperloop/ru.slybeaver.slycalendarview.SlyCalendarDialog$Callback.js:55:53) [ERROR] : TiExceptionHandler: [ERROR] : TiExceptionHandler: org.appcelerator.kroll.runtime.v8.V8Function.nativeInvoke(Native Method) [ERROR] : TiExceptionHandler: org.appcelerator.kroll.runtime.v8.V8Function.callSync(V8Function.java:55) [ERROR] : TiExceptionHandler: org.appcelerator.kroll.runtime.v8.V8Function.call(V8Function.java:41) [ERROR] : TiExceptionHandler: hyperloop.HyperloopInvocationHandler.invoke(HyperloopInvocationHandler.java:58) [ERROR] : TiExceptionHandler: java.lang.reflect.Proxy.invoke(Proxy.java:913) [ERROR] : TiExceptionHandler: $Proxy0.onDataSelected(Unknown Source) [ERROR] : TiExceptionHandler: ru.slybeaver.slycalendarview.SlyCalendarView$2.onClick(SlyCalendarView.java:133) [ERROR] : TiExceptionHandler: android.view.View.performClick(View.java:6294) [ERROR] : TiExceptionHandler: android.view.View$PerformClick.run(View.java:24770) [ERROR] : TiExceptionHandler: android.os.Handler.handleCallback(Handler.java:790) [ERROR] : V8Exception: Exception occurred at /hyperloop/ru.slybeaver.slycalendarview.SlyCalendarDialog$Callback.js:32: Uncaught TypeError: Cannot read property 'apiName' of null {noformat} This error is happening when we click *Save* button (see attached screenshots for Save button UI) either without selecting any date or after selecting only start or single date. Selecting start and end dates both is giving correct/expected results. Also note that I tried this in native Android sample app using Android Studio and it's not crashing there in any cases. Seems it's pretty related to *Hyperloop* if any argument in listener callback method is found as null. *_Sample code for reproducing this error:_*
var AppCompatActivity = require('android.support.v7.app.AppCompatActivity');
var SlyCalendarDialog = require('ru.slybeaver.slycalendarview.SlyCalendarDialog');


function showCalendar(e){
    // need to pass support-fragment manager to this library
    var compatActivity = new AppCompatActivity(Ti.Android.currentActivity);

    new SlyCalendarDialog()
        .setSingle(false)
        .setCallback(new SlyCalendarDialog.Callback({
            onCancelled : function () {
                alert('calendar dialog cancelled');
            },
    		onDataSelected: function(firstDate, secondDate, hours, minutes) {
    			try {
                                Ti.API.info('firstDate - ' + firstDate);
        			Ti.API.info('secondDate - ' + secondDate);
        			Ti.API.info('hours - ' + hours);
        			Ti.API.info('minutes - ' + minutes);
                } catch (exc) {
                    Ti.API.error('exc - ' + exc);
                }
    		}
    	}))
        .show(compatActivity.getSupportFragmentManager(), "TAG_SLYCALENDAR");
}

var win = Ti.UI.createWindow();

var btn = Ti.UI.createButton({ 'title' :'Show Calendar' });
btn.addEventListener('click', showCalendar);

win.add(btn);

win.open();
*_Steps to reproduce:_* 1- Run the sample code in a test app after properly adding the attached .aar file. 2- Tap on Show Calendar button, the calendar dialog should open now. 3- Without selecting any date, tap on Save button inside dialog. 4- This error should come up. Tap on Continue to run further tests. 5- Now open the calendar dialog again and select a single date and tap on Save, the error will come up again. 6- Open the dialog again and select start and end dates and tap on Save, this time it will print the result properly. I cannot find any work-around here as of now, so I am looking forward to get a quick fix for this bug as early as possible. _*Note:*_ I have attached the .aar file for this library and the required screenshots (UI theme may differ but that should not affect the code functionality at all). Also here's [My Own KitchenSink](https://drive.google.com/file/d/17U1IFY1rNSjy_o1X0En_qVFyQAPNJOHH/view?usp=sharing) test app I have been using for all sample stuffs. You can try this sample in this test app.

Attachments

FileDateSize
Calendar Dialog.png2018-12-16T15:50:40.000+000033033
Calendar Dialog Result Without Selecting Any Date.png2018-12-16T15:50:40.000+000070779
slycalendarview-0.0.8.aar2018-12-16T15:49:05.000+000048338

Comments

  1. Rakhi Mitro 2018-12-18

    Hello, Thanks for reporting this. Are you experiencing this in all android devices or sepcifice one?
  2. Prashant Saini 2018-12-18

  3. Rakhi Mitro 2018-12-18

    [~prashant_saini], Thanks for your feedback. Did you follow [this](https://docs.axway.com/bundle/Titanium_SDK_allOS_en/page/android_hyperloop_programming_guide.html#AndroidHyperloopProgrammingGuide-UsingThird-partylibraries ) accordingly? Unable to reproduce the same error. It would be helpful if you can share your full sample test project with us.
  4. Prashant Saini 2018-12-18

    Yes, I had followed the steps properly and that's why I am able to implement that library otherwise I would not have seen this error at all. I believe you have not followed the steps properly as I have defined the steps to reproduce as clear as possible and it will surely reproduce the error. I have also added the sample screenshot for that error and the other ticket also has the same issue. Please provide me your environment details you have used and also the sample code so I can test it here and match with my code. It's getting quite disappointing that you guys are unable to test the stuffs properly despite of the very detailed informations provided by reporting users.
  5. Prashant Saini 2018-12-18

    I have already provided the sample code (a single file code) and the .aar file and the related screenshots, now I do not understand what else you need from me as I have nothing to provide now. I would suggest to please focus on the *_Steps to Reproduce_* properly. I am still able to reproduce this issue as many times as I am tapping on *Save* button in calendar dialog without selecting any date.
  6. Rakhi Mitro 2018-12-18

    [~prashant_saini], Thanks for your feedback. We are closely investigating this issue. Hope we will get back to soon.

JSON Source