liferay / liferay-mobile-sdk

Other
47 stars 56 forks source link

CalendarbookingService causes App Crash on Android Platform #13

Closed morningstar84 closed 9 years ago

morningstar84 commented 9 years ago

I want to report a bug related to the use of CalendarbookingService on android platform. Specifically, the invocation of the "search" function causes a crash of the application that you can not manage even with a try-catch block. An example of invocation is the following: CalendarbookingService calendarbookingService = new CalendarbookingService(session);

            long companyId = 10157;

            JSONArray groupIdArray = new JSONArray();
            groupIdArray.put(13601);

            JSONArray calendarIds = new JSONArray();
            calendarIds.put(13904);

            JSONArray calendarResIdArray = new JSONArray();
            calendarResIdArray.put(13630);

            JSONArray statuses = new JSONArray();
            statuses.put(0);

            JSONArray last = calendarbookingService.search(companyId, groupIdArray, calendarIds, calendarResIdArray, -1l , null, startTime, endTime, true, statuses, -1, -1, null);

The same code runs without problems on the iOs platform.

Thanks in advance for the help .

brunofarache commented 9 years ago

Which version are you using and which error are you getting on the logs?

morningstar84 commented 9 years ago

I'm using the latest version of SDK (6.2.0.9) and I get a "RuntimeException" thats kills the app even if the code is surrounded by a try-catch block that catch "Exception"

brunofarache commented 9 years ago

Can you catch the RuntimeException to see what's wrong? In Android, when they are not caught, they also show up in the console.

morningstar84 commented 9 years ago

"RuntimeException" is subclass of "Exception" but it fails to manage it. As you can see in the screenshot, the detail of exception is void while running in debug mode.

bug

brunofarache commented 9 years ago

Ah, maybe if you were catching Throwable instead it would catch it?

Anyways, there's a newer version of the Android SDK that fixes an issue that maybe related to yours (issue #9). I have published it to Maven but I guess you are adding the .jar manually, I have also added it to the releases page:

https://github.com/liferay/liferay-mobile-sdk/releases/tag/android-6.2.0.14

brunofarache commented 9 years ago

You are using services that you generated yourself, right? You should also re-generate with the latest builder, because issue #9 also changes the way services are generated.

morningstar84 commented 9 years ago

Yes, I made a custom service. I regenerated the services using the latest SDK: now the catch-block works as it should but catch (or throw) a void Exception (null). In the debugger I can't see nothing interesting.

Thanks for the help

morningstar84 commented 9 years ago

I made some changes in my code with an explicit declaration of long type:

long companyId = 10157l;

            JSONArray groupIdArray = new JSONArray();
            groupIdArray.put(13601l);

            JSONArray calendarIds = new JSONArray();
            calendarIds.put(13904l);

            JSONArray calendarResIdArray = new JSONArray();
            calendarResIdArray.put(13630l);

            JSONArray statuses = new JSONArray();
            statuses.put(0l);

            JSONArray last = calendarbookingService.search(companyId, groupIdArray, calendarIds, calendarResIdArray, -1l , null, startTime, endTime, true, statuses, -1, -1, null);

Now, I'm getting a detail exception:

"com.liferay.mobile.android.exception.ServerException: No JSON web service action with path /calendar-portlet/calendarbooking/search and method null for /"

morningstar84 commented 9 years ago

I solved the issue. The function search doesn't support "null" as value for keyword. JSONArray last = calendarbookingService.search(companyId, groupIdArray, calendarIds, calendarResIdArray, -1l , "", startTime, endTime, true, statuses, -1, -1, null);

And finally i get the result

brunofarache commented 9 years ago

I see, that error means the server can't infer which method you are trying to call.