{ "id": "166170", "key": "TIMOB-24420", "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": { "id": "11", "description": "Is not a bug in our product", "name": "Not Our Bug" }, "resolutiondate": "2017-03-08T22:21:33.000+0000", "created": "2017-02-21T17:58:09.000+0000", "priority": { "name": "None", "id": "6" }, "labels": [], "versions": [ { "id": "16980", "description": "New V8", "name": "Release 6.0.0", "archived": false, "released": true, "releaseDate": "2016-11-15" }, { "id": "18154", "name": "Release 6.0.1", "archived": false, "released": true, "releaseDate": "2016-12-21" } ], "issuelinks": [], "assignee": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "updated": "2017-05-31T22:30:56.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" }, { "id": "13715", "name": "Hyperloop", "description": "Hyperloop project" } ], "description": "h5. Problem Description:\r\n\r\nUnable to access method getApplicationContext in android.content.Context class using Hyperloop while trying to use thord party library Localytics for Android. (attached the third party library as well)\r\n\r\nh5. Steps to reproduce:\r\n1. Create a classic app and enable Hyperloop.\r\n2. Run the attached (app.js) code.\r\n3. You will see the below error message:\r\n\r\n{code}\r\n[ERROR] : TiExceptionHandler: (main) [42,42] ----- Titanium Javascript Runtime Error -----\r\n[ERROR] : TiExceptionHandler: (main) [0,42] - In /app.js:5,56\r\n[ERROR] : TiExceptionHandler: (main) [0,42] - Message: Uncaught SyntaxError: Invalid or unexpected token\r\n[ERROR] : TiExceptionHandler: (main) [0,42] - Source: var appContext = (new context).getApplicationContext();​​​\r\n[DEBUG] : OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true\r\n[DEBUG] : D/ : HostConnection::get() New Host Connection established 0xe98bfe40, tid 1965\r\n[ERROR] : V8Exception: Exception occurred at /app.js:5: Uncaught SyntaxError: Invalid or unexpected token\r\n{code}\r\n\r\nh5. Expected Result:\r\nTo be able to get the ApplicationContext in order to use it for localytics method parameter.\r\n\r\n\r\n", "attachment": [ { "id": "61651", "filename": "app.js", "author": { "name": "nmishra", "key": "nmishra", "displayName": "Neeraj Mishra", "active": true, "timeZone": "America/Phoenix" }, "created": "2017-02-21T17:58:43.000+0000", "size": 218, "mimeType": "text/javascript" }, { "id": "61650", "filename": "localytics.jar", "author": { "name": "nmishra", "key": "nmishra", "displayName": "Neeraj Mishra", "active": true, "timeZone": "America/Phoenix" }, "created": "2017-02-21T17:58:50.000+0000", "size": 530347, "mimeType": "application/java-archive" } ], "flagged": false, "summary": "Hyperloop : Android: Unable to access getApplicationContext method in android.content.Context class", "creator": { "name": "nmishra", "key": "nmishra", "displayName": "Neeraj Mishra", "active": true, "timeZone": "America/Phoenix" }, "subtasks": [], "reporter": { "name": "nmishra", "key": "nmishra", "displayName": "Neeraj Mishra", "active": true, "timeZone": "America/Phoenix" }, "environment": "Operating System\r\n Name = Mac OS X\r\n Version = 10.12.3\r\n Architecture = 64bit\r\n # CPUs = 8\r\n Memory = 17179869184\r\nNode.js\r\n Node.js Version = 4.7.3\r\n npm Version = 2.15.11\r\nTitanium CLI\r\n CLI Version = 5.0.11\r\nTitanium SDK\r\n SDK Version = 6.0.1.GA\r\n SDK Path = /Users/nmishra/Library/Application Support/Titanium/mobilesdk/osx/6.0.1.GA\r\n Target Platform = android\r\n\r\n", "closedSprints": [ { "id": 847, "state": "closed", "name": "2017 Sprint 05 SDK", "startDate": "2017-02-26T17:39:21.095Z", "endDate": "2017-03-12T17:39:00.000Z", "completeDate": "2017-03-12T19:14:38.838Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "408137", "author": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "body": "[~nmishra], the code they are using is wrong. {{android.content.context}} is an abstract class which cannot be instantiated. Also it is not possible to hook into the application's {{onCreate}} method from Hyperloop, which is the designated place to run {{Localytics.autoIntegrate()}} according to the documentation of the Localytics SDK.\r\n\r\nThey can try this, but it won't log the first activity launched.\r\n{code}\r\nvar Activity = require('android.app.Activity');\r\nvar currentActivity = new Activity(Ti.Android.currentActivity);\r\nvar Localytics = require('com.localytics.android.Localytics');\r\nLocalytics.autoIntegrate(currentActivity.getApplicationContext());\r\nLocalytics.setLoggingEnabled(true);\r\n// Example how to use listeners\r\nvar AnalyticsListenerAdapter = require('com.localytics.android.AnalyticsListenerAdapter');\r\nvar listener = new AnalyticsListenerAdapter({\r\n localyticsSessionWillOpen: function(isFirst, isUpgrade, isResume) {\r\n // ... do something ...\r\n Ti.API.debug('Localytics session will open');\r\n }\r\n});\r\nLocalytics.setAnalyticsListener(listener);\r\n{code}\r\n\r\nFor a full integration they could write a module, place the Localytics SDK there and include a method annotated with {{@Kroll.onAppCreate}} where the Localytics SDK can be properly initialized. After that they can then continue to use Hyperloop to make all other calls to the Localytics SDK.", "updateAuthor": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "created": "2017-02-28T15:54:16.000+0000", "updated": "2017-02-28T15:54:16.000+0000" }, { "id": "408177", "author": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "body": "It's a key provided by Localytics to identify the app. Please see their docs: https://docs.localytics.com/dev/android.html#modify-androidmanifest-android and our docs how to add that: http://docs.appcelerator.com/platform/latest/#!/guide/Maintaining_a_Custom_AndroidManifest.xml\r\n\r\n", "updateAuthor": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "created": "2017-02-28T23:06:18.000+0000", "updated": "2017-02-28T23:06:18.000+0000" }, { "id": "408178", "author": { "name": "nmishra", "key": "nmishra", "displayName": "Neeraj Mishra", "active": true, "timeZone": "America/Phoenix" }, "body": "[~jvennemann]: Thanks much. It will help.", "updateAuthor": { "name": "nmishra", "key": "nmishra", "displayName": "Neeraj Mishra", "active": true, "timeZone": "America/Phoenix" }, "created": "2017-02-28T23:19:57.000+0000", "updated": "2017-02-28T23:19:57.000+0000" }, { "id": "409952", "author": { "name": "nmishra", "key": "nmishra", "displayName": "Neeraj Mishra", "active": true, "timeZone": "America/Phoenix" }, "body": "[~jvennemann]: This worked at customer end too and we can close this jira too. Thanks for your help.", "updateAuthor": { "name": "nmishra", "key": "nmishra", "displayName": "Neeraj Mishra", "active": true, "timeZone": "America/Phoenix" }, "created": "2017-03-08T22:12:44.000+0000", "updated": "2017-03-08T22:12:44.000+0000" }, { "id": "420723", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket with reference to the above comments.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-05-31T22:30:56.000+0000", "updated": "2017-05-31T22:30:56.000+0000" } ], "maxResults": 7, "total": 7, "startAt": 0 } } }