Titanium currently support "Java 7" language features.

      In 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.

      Android has limited support for Java 8 language features which Google documents below. Note that older Android OS versions support less Java 8 features.

      Recommended Solution:
      We 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.

      Support can be added via the following "build.gradle" settings...

      android {
      	compileOptions {
      		sourceCompatibility JavaVersion.VERSION_1_8
      		targetCompatibility JavaVersion.VERSION_1_8
      	// When we add Kotlin support in the future,
      	// then we must do the following as well.
      	kotlinOptions {
      		jvmTarget = "1.8"

      We 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 code, I recommend that we change the following code...

      protected void setOnClickListener(View view)
      	view.setOnClickListener(new OnClickListener() {
      		public void onClick(View view)
      			fireEvent(TiC.EVENT_CLICK, dictFromEvent(lastUpEvent));
     use a Java 8 lambda as follows...

      protected void setOnClickListener(View view)
      	view.setOnClickListener((clickedView) -> {
      		fireEvent(TiC.EVENT_CLICK, dictFromEvent(lastUpEvent));

      We can then test the above via a Titanium Ti.UI.Button object's "click" event.

      var window = Ti.UI.createWindow();
      var button = Ti.UI.createButton({ title: "Show Alert" });
      button.addEventListener("click", function() {
      	alert("Button clicked!");


          Issue Links



              • Assignee:
                jquick Joshua Quick
                jquick Joshua Quick
              • Watchers:
                6 Start watching this issue


                • Created:

                  Backbone Issue Sync

                  • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                    Git Source Code