Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-17747

Android: Native module onStart() lifecycle method never called for Alloy project


    • Type: Bug
    • Status: Closed
    • Priority: High
    • Resolution: Done
    • Affects Version/s: Release 3.3.0
    • Fix Version/s: Release 4.1.0
    • Component/s: Android
    • Labels:
    • Environment:

      Titanium SDK 3.3.0.GA
      CLI version 3.3.0,
      Titanium SDK version 3.2.3.GA, 3.3.0.GA
      Android Device, Nexus 5 -Android 4.2 and Emulator.
      Mac OS

    • Story Points:
    • Sprint:
      2015 Sprint 12 SDK


      Problem Description

      I have created a native module that has some code in an onStart() method - when importing this module in my alloy controller using require(), the onStart() method is called when the root activity is started when using Titanium SDK 3.2.3.GA, but when using 3.3.0, it is never called.

      I have properly declared the module in my tiapp.xml and my onStart() method is pretty simple:

      	public void onStart(Activity activity)
      		// This method is called when the module is loaded and the root context is started
      		Log.d(TAG, "[MODULE LIFECYCLE EVENT] start");

      In 3.2.3.GA I see the debug message in the logcat output - but using 3.3.0.GA I never see it (however I do see the onPause and onStop lifecycle methods are properly called.

      My native module depends on some initialization code in onStart that cannot be moved to onAppCreate, so it's currently failing as onStart is never called (nor is onPause which is a bit suspect).

      Also, for a non-Alloy app, this does not happen – all of the lifecycle methods, including onStart are called as expected.

      Steps to reproduce.

      1. Download the module from this link
      2. Create a titanium classic project
      3. Paste this code:

      var win = Ti.UI.createWindow({
      var label = Ti.UI.createLabel();
      if (Ti.Platform.name == "android") {
          var mod = require('com.liferay.beacons');
          label.text = "module is => " + mod + "and checkAvailability says: " + mod.checkAvailability();
      } else {
          label.text = "liferay.beacons not supported on " + Ti.Platform.name;

      Steps to reproduce the issue with alloy (which is easier to reproduce)

      1. Create a new alloy project
      2. Paste this to index.js:

      var mod = require('com.liferay.beacons');
      $.label.text= "module is => " + mod + "and checkAvailability says: " + mod.checkAvailability();
      function doClick(e) {

      3. Run it in a device.


          Issue Links



              • Assignee:
                ingo Ingo Muschenetz
                james.falkner James Falkner
              • Watchers:
                0 Start watching this issue


                • Created:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    Sync status:
                    Last received:
                    Last sent:

                    Git Integration