title: React Native, Native Modules returns empty object - {}
body: <p>I've written native module for React Native, everything was done according to official documentation, but something went wrong, and Native Modules returns only empty object.</p>
  <p><strong>importing Native Modules in Component Home.js</strong></p>
  <p><em>All Module code was writen according to official docs</em></p>
  <pre><code>import {
    NativeModules
  } from 'react-native';
  
  const { OptionsPackage } = NativeModules;
  
  console.log(NativeModules) // {}
  </code></pre>
  <p><strong>MainApplication.java file</strong></p>
  <pre><code>        @Override
          protected List&lt;ReactPackage&gt; getPackages() {
            @SuppressWarnings(&quot;UnnecessaryLocalVariable&quot;)
            List&lt;ReactPackage&gt; packages = new PackageList(this).getPackages();
            // Packages that cannot be autolinked yet can be added manually here, for example:
            // packages.add(new MyReactNativePackage());
              packages.add(new OptionsPackage());
            return packages;
          }
  </code></pre>
  <p><strong>OptionsPackage.java file</strong></p>
  <pre><code>package package.name;
  import com.facebook.react.ReactPackage;
  import com.facebook.react.bridge.NativeModule;
  import com.facebook.react.bridge.ReactApplicationContext;
  import com.facebook.react.uimanager.ViewManager;
  
  import java.util.ArrayList;
  import java.util.Collections;
  import java.util.List;
  
  public class OptionsPackage implements ReactPackage {
  
      @Override
      public List&lt;ViewManager&gt; createViewManagers(ReactApplicationContext reactContext) {
          return Collections.emptyList();
      }
  
      @Override
      public List&lt;NativeModule&gt; createNativeModules(
              ReactApplicationContext reactContext) {
          List&lt;NativeModule&gt; modules = new ArrayList&lt;&gt;();
  
          modules.add(new OptionsModule(reactContext));
  
          return modules;
      }
  
  }
  </code></pre>
  <p><strong>OptionsModule.java</strong></p>
  <pre><code>package com.downloadmanager;
  
  import com.facebook.react.bridge.NativeModule;
  import com.facebook.react.bridge.ReactApplicationContext;
  import com.facebook.react.bridge.ReactContext;
  import com.facebook.react.bridge.ReactContextBaseJavaModule;
  import com.facebook.react.bridge.ReactMethod;
  
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.Map;
  import java.util.List;
  import java.io.InputStream;
  
  ... 
  public class OptionsModule extends ReactContextBaseJavaModule {
  
      ActivityManager activityManager;
      int currentSDK;
      ReactApplicationContext context;
  
      OptionsModule(ReactApplicationContext context) {
          super(context);
          this.activityManager = ((ActivityManager) context.getSystemService(ReactApplicationContext.ACTIVITY_SERVICE));
          context = context;
          currentSDK = android.os.Build.VERSION.SDK_INT;
      }
  
      @Override
      public String getName() {
          return &quot;123&quot;;
      }
  
      private Map packageInfoToMap(PackageInfo pi) {
          PackageManager pm = this.context.getPackageManager();
  
          long longVersionCode;
          Map&lt;String, Object&gt; AppInfo = new HashMap&lt;String, Object&gt;();
  
          if(Build.VERSION.SDK_INT &gt;= 28) {
              longVersionCode = pi.getLongVersionCode();
          } else
          {
              longVersionCode = pi.versionCode; }
  
          AppInfo.put(&quot;packageName&quot;, pi.packageName);
          AppInfo.put(&quot;versionName&quot;, pi.versionName);
          AppInfo.put(&quot;getLongVersionCode&quot;, longVersionCode);
          AppInfo.put(&quot;lastUpdateTime&quot;, (pi.lastUpdateTime));
          AppInfo.put(&quot;firstInstallTime&quot;, pi.firstInstallTime);
  
          String title = pi.applicationInfo.loadLabel(pm).toString();
          String description =  pi.applicationInfo.loadDescription(pm).toString();
          Drawable icon = pi.applicationInfo.loadIcon(pm);
  
  
          
          AppInfo.put(&quot;title&quot;, title);
          AppInfo.put(&quot;description&quot;, description);
          AppInfo.put(&quot;icon&quot;, icon);
  
          //get folder
  
          String apkDir = pi.applicationInfo.publicSourceDir;
          File file = new File(apkDir);
          double size = file.length();
  
          AppInfo.put(&quot;filePath&quot;, apkDir);
          AppInfo.put(&quot;size&quot;, size);
  
          return AppInfo;
      }
  
      @ReactMethod
      public List listOfApps(String type) {
          List&lt;PackageInfo&gt; packages = this.context.getPackageManager().getInstalledPackages(0);
          List&lt;Map&lt;String, Object&gt;&gt; listOfApps = new ArrayList();
  
          for (PackageInfo isPackage : packages) {
              boolean isSystem = (isPackage.applicationInfo.flags &amp; ApplicationInfo.FLAG_SYSTEM) == ApplicationInfo.FLAG_SYSTEM;
  
  
              if(type == &quot;systemOnly&quot; &amp;&amp; isSystem) {
                  listOfApps.add(this.packageInfoToMap(isPackage));
              } else if (type == &quot;nonSystem&quot; &amp;&amp; !isSystem) {
                  listOfApps.add(this.packageInfoToMap(isPackage));
              } else {
                  listOfApps.add(this.packageInfoToMap(isPackage));
              }
          }
  
          return listOfApps;
  
      }
  }
  
  
  </code></pre>