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

Android: Remove harmless activity errors/warnings logged on startup

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: Release 7.3.0
    • Fix Version/s: Release 7.3.0
    • Component/s: Android
    • Labels:
    • Story Points:
      1

      Description

      Summary:
      A Titanium 7.3.0 built Android app will log the following messages on startup.

      [ERROR] :  TiApplication: (main) [806,864] No valid root or current activity found for application instance
      [ERROR] :  TiApplication: (main) [3,867] No valid root or current activity found for application instance
      [ERROR] :  TiApplication: (main) [25,892] No valid root or current activity found for application instance
      [ERROR] :  TiApplication: (main) [13,905] No valid root or current activity found for application instance
      [ERROR] :  TiApplication: (main) [4,909] No valid root or current activity found for application instance
      [ERROR] :  TiApplication: (main) [1,910] No valid root or current activity found for application instance
      [ERROR] :  TiApplication: (main) [3,913] No valid root or current activity found for application instance
      [WARN] :   TiAndroid: (main) [2,915] Application instance no longer available. Unable to get current activity.
      [ERROR] :  TiApplication: (main) [1,916] No valid root or current activity found for application instance
      [WARN] :   TiAndroid: (main) [1,917] Application instance no longer available. Unable to get current activity.
      [WARN] :   TiAndroid: (main) [0,917] Application instance no longer available. Unable to get current activity.
      [ERROR] :  TiApplication: (main) [2,919] No valid root or current activity found for application instance
      [ERROR] :  TiApplication: (main) [6,925] No valid root or current activity found for application instance
      [ERROR] :  TiApplication: (main) [1,926] No valid root or current activity found for application instance
      [ERROR] :  TiApplication: (main) [2,928] No valid root or current activity found for application instance
      [ERROR] :  TiApplication: (main) [2,930] No valid root or current activity found for application instance
      

      These errors/warnings are actually harmless noise triggered by Titanium when loading its core modules (ie: Ti, Ti.UI, Ti.Platform, etc.) when the Android Application instance gets created, but before an Activity has been created. There is no Activity to fetch at this point in the code and the modules already correctly handle null and will fetch a valid Activity later when needed.

      Recommended Solution:
      It's the responsibility of the caller to handle the null case, not the method.

      So, remove the "Application instance no longer available." log message in AndroidModule.getCurrentActivity() here...
      https://github.com/appcelerator/titanium_mobile/blob/7_3_X/android/modules/android/src/java/ti/modules/titanium/android/AndroidModule.java#L580

      And remove the "No valid root or current activity found for application instance" log message from TiApplication.getRootOrCurrentActivity() here...
      https://github.com/appcelerator/titanium_mobile/blob/7_3_X/android/titanium/src/java/org/appcelerator/titanium/TiApplication.java#L297

      Side Note:
      The TiApplication.getInstance() call can never return null. The Android Application class is always the 1st object to be created within the app and is guaranteed to exist for the lifetime of the app. There is no point in doing a null check on it. Nor do we need to keep a weak reference to it within TiApplication. A normal strong reference will suffice.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jquick Joshua Quick
                Reporter:
                jquick Joshua Quick
                Reviewer:
                Gary Mathews
              • Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  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