{ "id": "171042", "key": "TIMOB-25782", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": null, "resolutiondate": null, "created": "2018-02-06T17:18:19.000+0000", "priority": null, "labels": [], "versions": [], "issuelinks": [], "assignee": null, "updated": "2018-04-05T09:36:07.000+0000", "status": { "description": "This issue was once resolved, but the resolution was deemed incorrect. From here issues are either marked assigned or resolved.", "name": "Reopened", "id": "4", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [ { "id": "13715", "name": "Hyperloop", "description": "Hyperloop project" } ], "description": "While trying to access Google Fit History data, the onSuccess is called, but the DataReadResponse methods can't be successfully called to retrieve data.\r\n\r\nTest code:\r\n\r\n\r\n{code:java}\r\nFitness.getHistoryClient(windowActivity, GoogleSignIn.getLastSignedInAccount(windowActivity))\r\n .readData(new DataReadRequest.Builder()\r\n // The data request can specify multiple data types to return, effectively\r\n // combining multiple data queries into one call.\r\n // In this example, it's very unlikely that the request is for several hundred\r\n // datapoints each consisting of a few steps and a timestamp. The more likely\r\n // scenario is wanting to see how many steps were walked per day, for 7 days.\r\n .aggregate(DataType.TYPE_STEP_COUNT_DELTA, DataType.AGGREGATE_STEP_COUNT_DELTA)\r\n // Analogous to a \"Group By\" in SQL, defines how data should be aggregated.\r\n // bucketByTime allows for a time span, whereas bucketBySession would allow\r\n // bucketing by \"sessions\", which would need to be defined in code.\r\n .bucketByTime(1, TimeUnit.DAYS)\r\n .setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)\r\n .build())\r\n .addOnSuccessListener(new OnSuccessListener({\r\n onSuccess: function(e) {\r\n var dataResponse = new DataReadResponse(e);\r\n\r\n console.log(\"onSuccess()\" + e.toString() + \"/\" + dataResponse.toString());\r\n console.log(\"buckets size: \" + dataResponse.getDataSets().size());\r\n }\r\n }))\r\n .addOnFailureListener(new OnFailureListener({\r\n onFailure: function(e) {\r\n console.log(\"onFailure()\");\r\n }\r\n }));\r\n{code}\r\n\r\n\r\nThis error is happening \r\n[INFO] onSuccess()com.google.android.gms.fitness.result.DataReadResponse@645f427/com.google.android.gms.fitness.result.DataReadResponse@95706d4\r\n\r\n[WARN] W/System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.List com.google.android.gms.fitness.result.DataReadResult.getDataSets()' on a null object reference\r\n[WARN] W/System.err: \tat com.google.android.gms.fitness.result.DataReadResponse.getDataSets(Unknown Source:6)\r\n[WARN] W/System.err: \tat java.lang.reflect.Method.invoke(Native Method)\r\n[WARN] W/System.err: \tat hyperloop.BaseProxy.invokeMethod(BaseProxy.java:157)\r\n[WARN] W/System.err: \tat hyperloop.InstanceProxy.invokeMethod(InstanceProxy.java:184)\r\n[WARN] W/System.err: \tat hyperloop.BaseProxy.callNativeFunction(BaseProxy.java:129)\r\n[WARN] W/System.err: \tat org.appcelerator.kroll.runtime.v8.V8Function.nativeInvoke(Native Method)\r\n[WARN] W/System.err: \tat org.appcelerator.kroll.runtime.v8.V8Function.callSync(V8Function.java:57)\r\n[WARN] W/System.err: \tat org.appcelerator.kroll.runtime.v8.V8Function.call(V8Function.java:43)\r\n[WARN] W/System.err: \tat hyperloop.HyperloopInvocationHandler.invoke(HyperloopInvocationHandler.java:58)\r\n[WARN] W/System.err: \tat java.lang.reflect.Proxy.invoke(Proxy.java:913)\r\n[WARN] W/System.err: \tat $Proxy0.onSuccess(Unknown Source)\r\n[WARN] W/System.err: \tat com.google.android.gms.tasks.zzj.run(Unknown Source:27)\r\n[WARN] W/System.err: \tat android.os.Handler.handleCallback(Handler.java:790)\r\n[WARN] W/System.err: \tat android.os.Handler.dispatchMessage(Handler.java:99)\r\n[WARN] W/System.err: \tat android.os.Looper.loop(Looper.java:164)\r\n[WARN] W/System.err: \tat android.app.ActivityThread.main(ActivityThread.java:6494)\r\n[WARN] W/System.err: \tat java.lang.reflect.Method.invoke(Native Method)\r\n[WARN] W/System.err: \tat com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)\r\n[WARN] W/System.err: \tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)", "attachment": [ { "id": "64815", "filename": "googlefittest.zip", "author": { "name": "yankovalera@gmail.com", "key": "yankovalera@gmail.com", "displayName": "Yanko Valera", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-02-07T08:58:19.000+0000", "size": 5183082, "mimeType": "application/zip" } ], "flagged": false, "summary": "Cannot Access Google Fit Read Result", "creator": { "name": "yankovalera@gmail.com", "key": "yankovalera@gmail.com", "displayName": "Yanko Valera", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "yankovalera@gmail.com", "key": "yankovalera@gmail.com", "displayName": "Yanko Valera", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "434109", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Your environment is completely missing, we cannot help until thats available, sorry.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-02-06T18:17:05.000+0000", "updated": "2018-02-06T18:17:05.000+0000" }, { "id": "434122", "author": { "name": "yankovalera@gmail.com", "key": "yankovalera@gmail.com", "displayName": "Yanko Valera", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I'm using SDK7.0.1, Hyperloop 3.0.1/3.0.2. Google Play Fitness API 11.8.0. Testing in Google Nexus 5X running Android 8.1.0 let me know if you need more details", "updateAuthor": { "name": "yankovalera@gmail.com", "key": "yankovalera@gmail.com", "displayName": "Yanko Valera", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-02-06T19:09:59.000+0000", "updated": "2018-02-06T19:09:59.000+0000" }, { "id": "434145", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "[~jvennemann] The {{java.util.List}} related method should be fixed in 3.0.2, do you see whats wrong here?", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-02-07T08:16:04.000+0000", "updated": "2018-02-07T08:16:04.000+0000" }, { "id": "434154", "author": { "name": "yankovalera@gmail.com", "key": "yankovalera@gmail.com", "displayName": "Yanko Valera", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I've attached the full source code to help to reproduce issue", "updateAuthor": { "name": "yankovalera@gmail.com", "key": "yankovalera@gmail.com", "displayName": "Yanko Valera", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-02-07T08:59:05.000+0000", "updated": "2018-02-07T08:59:05.000+0000" }, { "id": "434347", "author": { "name": "mrahman", "key": "mrahman", "displayName": "Mostafizur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "body": "[~yankovalera@gmail.com], Thanks for sharing the source code.Tested the sample code on an android device and unable to reproduce the error. Can you please provide the exact test steps to reproduce this on our end?\r\n\r\nBest", "updateAuthor": { "name": "mrahman", "key": "mrahman", "displayName": "Mostafizur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "created": "2018-02-12T05:43:46.000+0000", "updated": "2018-02-12T05:43:46.000+0000" }, { "id": "434353", "author": { "name": "yankovalera@gmail.com", "key": "yankovalera@gmail.com", "displayName": "Yanko Valera", "active": true, "timeZone": "America/Los_Angeles" }, "updateAuthor": { "name": "yankovalera@gmail.com", "key": "yankovalera@gmail.com", "displayName": "Yanko Valera", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-02-12T08:39:58.000+0000", "updated": "2018-02-12T08:41:40.000+0000" }, { "id": "435381", "author": { "name": "yankovalera@gmail.com", "key": "yankovalera@gmail.com", "displayName": "Yanko Valera", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hi, were you able to reproduce this issue?\r\n\r\nRegards", "updateAuthor": { "name": "yankovalera@gmail.com", "key": "yankovalera@gmail.com", "displayName": "Yanko Valera", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-03-08T10:15:35.000+0000", "updated": "2018-03-08T10:15:35.000+0000" }, { "id": "436213", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Okay, so I spent some time validating this, since there are no known Android Hyperloop issues where classes are not recognized. I focussed on your following code:\r\n{code:js}\r\nonSuccess: function(e) {\r\n var dataResponse = new DataReadResponse(e);\r\n \r\n console.log(\"onSuccess()\" + e.toString() + \"/\" + dataResponse.toString());\r\n console.log(\"buckets size: \" + dataResponse.getDataSets().size());\r\n }\r\n{code}\r\nYou are trying to create a new {{DataReadResponse}} instance from {{e}}, which is weird because the {{onSuccess}} callback already returns {{DataReadResponse dataReadResult}}, so it's a valid {{DataReadResponse}} instance. The concrete error is that {{dataResponse}} is null, which may be very possible due to instantiating a custom version of it (cloning it). Looking at [this snippet|https://github.com/googlesamples/android-fit/blob/master/BasicHistoryApi/app/src/main/java/com/google/android/gms/fit/samples/basichistoryapi/MainActivity.java#L151-L155], they pass the callback property to an [own method|https://github.com/googlesamples/android-fit/blob/master/BasicHistoryApi/app/src/main/java/com/google/android/gms/fit/samples/basichistoryapi/MainActivity.java#L247-L267] and extract the response there. \r\n\r\nSo to see if you have a valid instance, you can try the following inside the {{onSuccess}}\r\n{code:js}\r\nonSuccess: function(dataResponse) {\r\n console.log(\"Size of Buckets: \" + dataResponse.getBuckets().size());\r\n console.log(\"Size of Data Sets: \" + dataResponse.getDataSets().size());\r\n}\r\n{code}\r\nBased on which one if it is non-empty, you can loop them with a typical JS-for-loop and dump the native {{Bucket}} or {{DataSet}} for it's contents.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-04-03T08:34:20.000+0000", "updated": "2018-04-03T08:34:48.000+0000" }, { "id": "436232", "author": { "name": "yankovalera@gmail.com", "key": "yankovalera@gmail.com", "displayName": "Yanko Valera", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hi Hans, I've tried your code and now I get\r\n\r\n\r\n{code:java}\r\n[ERROR] TiExceptionHandler: (main) [485,961] ----- Titanium Javascript Runtime Error -----\r\n[ERROR] TiExceptionHandler: (main) [0,962] - Message: Uncaught TypeError: dataResponse.getBuckets is not a function\r\n[ERROR] TiExceptionHandler: (main) [0,962] - Source: console.log('Size of Buckets: '+dataResponse.getBuckets().size()),\r\ndataResponse.getBuckets is not a function\r\n{code}\r\n\r\n\r\n", "updateAuthor": { "name": "yankovalera@gmail.com", "key": "yankovalera@gmail.com", "displayName": "Yanko Valera", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-04-03T15:34:02.000+0000", "updated": "2018-04-03T15:34:19.000+0000" }, { "id": "436234", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "And you renamed {{e}} to {{dataResponse}}? What does {{dataResponse}} consist of when you log it?", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-04-03T15:40:47.000+0000", "updated": "2018-04-03T15:40:47.000+0000" }, { "id": "436235", "author": { "name": "yankovalera@gmail.com", "key": "yankovalera@gmail.com", "displayName": "Yanko Valera", "active": true, "timeZone": "America/Los_Angeles" }, "body": "My current code is \r\n\r\n{code:java}\r\nonSuccess: function(dataResponse) {\r\n console.log(typeof(dataResponse));\r\n console.log(\"Size of Buckets: \" + dataResponse.getBuckets().size());\r\n console.log(\"Size of Data Sets: \" + dataResponse.getDataSets().size());\r\n }\r\n{code}\r\n\r\nThe log says typeof(dataResponse) is \r\n[INFO] object\r\n\r\n", "updateAuthor": { "name": "yankovalera@gmail.com", "key": "yankovalera@gmail.com", "displayName": "Yanko Valera", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-04-03T15:42:27.000+0000", "updated": "2018-04-03T15:42:27.000+0000" }, { "id": "436304", "author": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~yankovalera@gmail.com] let's see what dataResponse contains:\r\n{code:js}\r\nonSuccess: function(dataResponse) {\r\n console.log(JSON.stringify(Object.keys(dataResponse), null, 1));\r\n}\r\n{code}\r\n", "updateAuthor": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-04-04T21:15:28.000+0000", "updated": "2018-04-04T21:15:28.000+0000" }, { "id": "436531", "author": { "name": "yankovalera@gmail.com", "key": "yankovalera@gmail.com", "displayName": "Yanko Valera", "active": true, "timeZone": "America/Los_Angeles" }, "body": "This the output\r\n\r\n[INFO] [\r\n[INFO] \"$native\",\r\n[INFO] \"_hasPointer\",\r\n[INFO] \"_private\"\r\n[INFO] ]", "updateAuthor": { "name": "yankovalera@gmail.com", "key": "yankovalera@gmail.com", "displayName": "Yanko Valera", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-04-05T09:36:07.000+0000", "updated": "2018-04-05T09:36:07.000+0000" } ], "maxResults": 15, "total": 15, "startAt": 0 } } }