{ "id": "174260", "key": "TIMOB-27472", "fields": { "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "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": [ { "id": "20033", "name": "Release 9.0.0", "archived": false, "released": true, "releaseDate": "2020-03-18" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2020-01-30T16:13:49.000+0000", "created": "2019-10-16T00:15:23.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "android", "d8", "dexer", "java", "modules" ], "versions": [], "issuelinks": [ { "id": "57987", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "171384", "key": "TIMOB-25896", "fields": { "summary": "Android: Add Kotlin language support for modules", "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" } }, "priority": { "name": "Medium", "id": "3" }, "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false } } } }, { "id": "57862", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "173207", "key": "TIMOB-26919", "fields": { "summary": "Android: Support d8 dexer.", "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" } }, "priority": { "name": "Medium", "id": "3" }, "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "subtask": false } } } } ], "assignee": { "name": "ybanev", "key": "ybanev", "displayName": "Yordan Banev", "active": true, "timeZone": "Europe/Athens" }, "updated": "2020-01-30T16:13:49.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" } ], "description": "*Summary:*\r\nTitanium currently support \"Java 7\" language features.\r\n\r\nIn Titanium 9.0.0, we would like to add \"Java 8\" language features for the core SDK and all modules. This is needed since some 3rd party Android libraries use the Java 8 language, but we're currently unable to compile them into a module or via hyperloop.\r\n\r\n*Limitations:*\r\nAndroid has limited support for Java 8 language features which Google documents below. Note that older Android OS versions support less Java 8 features.\r\nhttps://developer.android.com/studio/write/java8-support#supported_features\r\n\r\n*Recommended Solution:*\r\nWe don't support Java 8 because Titanium is currently limited to using the \"dex\" command line tool in the Android SDK which only supports up to Java 7. Google's \"d8\" command line tool supports Java 8. If we update our Titanium build system to use gradle, then we can easily add support for this.\r\n\r\nSupport can be added via the following \"build.gradle\" settings...\r\n{code:groovy}\r\nandroid {\r\n\tcompileOptions {\r\n\t\tsourceCompatibility JavaVersion.VERSION_1_8\r\n\t\ttargetCompatibility JavaVersion.VERSION_1_8\r\n\t}\r\n\t// When we add Kotlin support in the future,\r\n\t// then we must do the following as well.\r\n\tkotlinOptions {\r\n\t\tjvmTarget = \"1.8\"\r\n\t}\r\n}\r\n{code}\r\n\r\n*Testing:*\r\nWe should add a Java 8 feature to our core Titanium code to prove that Java 8 compilation works for both the SDK and an app build. In our [TiUIView.java|https://github.com/appcelerator/titanium_mobile/blob/master/android/titanium/src/java/org/appcelerator/titanium/view/TiUIView.java] code, I recommend that we change the following code...\r\n{code:java}\r\nprotected void setOnClickListener(View view)\r\n{\r\n\tview.setOnClickListener(new OnClickListener() {\r\n\t\tpublic void onClick(View view)\r\n\t\t{\r\n\t\t\tfireEvent(TiC.EVENT_CLICK, dictFromEvent(lastUpEvent));\r\n\t\t}\r\n\t});\r\n}\r\n{code}\r\n\r\n...to use a Java 8 lambda as follows...\r\n{code:java}\r\nprotected void setOnClickListener(View view)\r\n{\r\n\tview.setOnClickListener((clickedView) -> {\r\n\t\tfireEvent(TiC.EVENT_CLICK, dictFromEvent(lastUpEvent));\r\n\t});\r\n}\r\n{code}\r\n\r\nWe can then test the above via a Titanium {{Ti.UI.Button}} object's \"click\" event.\r\n{code:javascript}\r\nvar window = Ti.UI.createWindow();\r\nvar button = Ti.UI.createButton({ title: \"Show Alert\" });\r\nbutton.addEventListener(\"click\", function() {\r\n\talert(\"Button clicked!\");\r\n});\r\nwindow.add(button);\r\nwindow.open();\r\n{code}\r\n", "attachment": [], "flagged": false, "summary": "Android: Add Java 8 support", "creator": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "closedSprints": [ { "id": 1175, "state": "closed", "name": "2019 Sprint 26", "startDate": "2019-12-16T06:12:12.044Z", "endDate": "2019-12-21T06:12:00.000Z", "completeDate": "2019-12-22T03:07:15.802Z", "originBoardId": 114 }, { "id": 1177, "state": "closed", "name": "2020 Sprint 2", "startDate": "2020-01-20T17:44:37.733Z", "endDate": "2020-01-31T17:44:00.000Z", "completeDate": "2020-01-31T16:57:44.689Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "453715", "author": { "name": "ybanev", "key": "ybanev", "displayName": "Yordan Banev", "active": true, "timeZone": "Europe/Athens" }, "body": "PR: https://github.com/appcelerator/titanium_mobile/pull/11434", "updateAuthor": { "name": "ybanev", "key": "ybanev", "displayName": "Yordan Banev", "active": true, "timeZone": "Europe/Athens" }, "created": "2020-01-15T16:09:07.000+0000", "updated": "2020-01-15T16:09:07.000+0000" }, { "id": "453770", "author": { "name": "ssekhri", "key": "ssekhri", "displayName": "Satyam Sekhri", "active": true, "timeZone": "America/Los_Angeles" }, "body": "FR Passed.\r\nWaiting for Jenkins.", "updateAuthor": { "name": "ssekhri", "key": "ssekhri", "displayName": "Satyam Sekhri", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2020-01-22T21:19:31.000+0000", "updated": "2020-01-22T21:19:31.000+0000" }, { "id": "453783", "author": { "name": "cwilliams", "key": "cwilliams", "displayName": "Christopher Williams", "active": true, "timeZone": "America/New_York" }, "body": "merged to master for 9.0.0", "updateAuthor": { "name": "cwilliams", "key": "cwilliams", "displayName": "Christopher Williams", "active": true, "timeZone": "America/New_York" }, "created": "2020-01-23T15:06:01.000+0000", "updated": "2020-01-23T15:06:01.000+0000" }, { "id": "453936", "author": { "name": "ssaddique", "key": "ssaddique", "displayName": "Sohail Saddique", "active": true, "timeZone": "Europe/London" }, "body": "Verified in build: 9.0.0.v20200130071742. Java8 has been fully implemented in Titanium for Android. Checked using testcase, and checking console\r\n\r\n\r\n{code:js}\r\n[INFO] TiApplication: (main) [342,342] Titanium Javascript runtime: v8\r\n{code}\r\n\r\nTicket closed.", "updateAuthor": { "name": "ssaddique", "key": "ssaddique", "displayName": "Sohail Saddique", "active": true, "timeZone": "Europe/London" }, "created": "2020-01-30T16:13:24.000+0000", "updated": "2020-01-30T16:13:37.000+0000" } ], "maxResults": 6, "total": 6, "startAt": 0 } } }