Problem Description:
Unable 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)
Steps to reproduce:
1. Create a classic app and enable Hyperloop.
2. Run the attached (app.js) code.
3. You will see the below error message:
[ERROR] : TiExceptionHandler: (main) [42,42] ----- Titanium Javascript Runtime Error -----
[ERROR] : TiExceptionHandler: (main) [0,42] - In /app.js:5,56
[ERROR] : TiExceptionHandler: (main) [0,42] - Message: Uncaught SyntaxError: Invalid or unexpected token
[ERROR] : TiExceptionHandler: (main) [0,42] - Source: var appContext = (new context).getApplicationContext();
[DEBUG] : OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
[DEBUG] : D/ : HostConnection::get() New Host Connection established 0xe98bfe40, tid 1965
[ERROR] : V8Exception: Exception occurred at /app.js:5: Uncaught SyntaxError: Invalid or unexpected token
Expected Result:
To be able to get the ApplicationContext in order to use it for localytics method parameter.
[~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'sonCreate
method from Hyperloop, which is the designated place to runLocalytics.autoIntegrate()
according to the documentation of the Localytics SDK. They can try this, but it won't log the first activity launched.For 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.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
[~jvennemann]: Thanks much. It will help.
[~jvennemann]: This worked at customer end too and we can close this jira too. Thanks for your help.
Closing ticket with reference to the above comments.