javascripttitaniumtitanium-sdk

failed to leave a valid exports object in titanium 9.0.1


I have added screenshot which i am getting error while building app for titanium

SDK : 9.0.1

For SDK 8.3.1 and 7.4.2 this error not coming app is working fine for this SDK version only having issue for 9.0.1

// requires:
// Set up device detector
var DeviceDetectClass = require('DeviceDetect');
var deviceDetect = new DeviceDetectClass();

this we importing in app.js enter image description here

enter image description here

enter image description here

enter image description here


Solution

  • Implicit global functions do no longer work in Titanium 9.0.0.GA or higher. Best way to fix this is put those functions in a standalone JS file, and require them in at the place you want to use them.

    So secondfile.js

    function checkNetworkStatus() {
    
    }
    
    module.exports = {
      checkNetworkStatus: checkNetworkStatus
    }
    

    Elsewhere in your app:

    require('secondfile').checkNetworkStatus();
    

    Another way is to put global functions like this in app.js. This is however not the recommended way.

    global.checkNetworkStatus = functon() {}
    

    Elsewhere in your app

    checkNetworkStatus();