title: React Native: error: cannot find symbol > new AppCenterReactNativeAnalyticsPackage(MainApplication.this
body: <p>I was getting a successful build with <code>android</code> in React Native until I added these:</p>
  
  <pre><code>"appcenter-analytics": "2.1.0",
      "appcenter-crashes": "2.1.0",
  </code></pre>
  
  <p>I am on:</p>
  
  <pre><code>"react": "16.8.6",
      "react-native": "0.60.4",
  </code></pre>
  
  <p>The error is:</p>
  
  <blockquote>
    <p>Error: Command failed: ./gradlew app:installDebug
    -PreactNativeDevServerPort=8081 Note: /Users/danale/Projects/NFIBEngage/node_modules/react-native-sentry/android/src/main/java/io/sentry/RNSentryModule.java
    uses or overrides a deprecated API. Note: Recompile with
    -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for
    details.
    /Users/danale/Projects/NFIBEngage/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:60:
    error: cannot find symbol
          new AppCenterReactNativeAnalyticsPackage(MainApplication.this, getResources().getString(R.string.appCenterAnalytics_whenToEnableAnalytics)),
                                                   ^   symbol:   class MainApplication   location: class PackageList
    /Users/danale/Projects/NFIBEngage/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:60:
    error: cannot find symbol
          new AppCenterReactNativeAnalyticsPackage(MainApplication.this, getResources().getString(R.string.appCenterAnalytics_whenToEnableAnalytics)),
                                                                                                          ^   symbol:   variable appCenterAnalytics_whenToEnableAnalytics<br>
    location: class string
    /Users/danale/Projects/NFIBEngage/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:61:
    error: cannot find symbol
          new AppCenterReactNativeCrashesPackage(MainApplication.this, getResources().getString(R.string.appCenterCrashes_whenToSendCrashes)),
                                                 ^   symbol:   class MainApplication   location: class PackageList
    /Users/danale/Projects/NFIBEngage/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:61:
    error: cannot find symbol
          new AppCenterReactNativeCrashesPackage(MainApplication.this, getResources().getString(R.string.appCenterCrashes_whenToSendCrashes)),
                                                                                                        ^   symbol:   variable appCenterCrashes_whenToSendCrashes   location:
    class string 4 errors</p>
    
    <p>FAILURE: Build failed with an exception.</p>
    
    <ul>
    <li>What went wrong: Execution failed for task ':app:compileDebugJavaWithJavac'.
    
    <blockquote>
      <p>Compilation failed; see the compiler error output for details.</p>
    </blockquote></li>
    </ul>
  </blockquote>
  
  <p>Apparently there is this <code>android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java</code> file that did not exist with the legacy version of this application:</p>
  
  <pre><code>package com.facebook.react;
  
  import android.app.Application;
  import android.content.Context;
  import android.content.res.Resources;
  
  import com.facebook.react.ReactPackage;
  import com.facebook.react.shell.MainReactPackage;
  import java.util.Arrays;
  import java.util.ArrayList;
  
  import com.nfibengage.BuildConfig;
  import com.nfibengage.R;
  
  // @react-native-community/async-storage
  import com.reactnativecommunity.asyncstorage.AsyncStoragePackage;
  // appcenter-analytics
  import com.microsoft.appcenter.reactnative.analytics.AppCenterReactNativeAnalyticsPackage;
  // appcenter-crashes
  import com.microsoft.appcenter.reactnative.crashes.AppCenterReactNativeCrashesPackage;
  // react-native-sentry
  import io.sentry.RNSentryPackage;
  // react-native-splash-screen
  import org.devio.rn.splashscreen.SplashScreenReactPackage;
  
  public class PackageList {
    private Application application;
    private ReactNativeHost reactNativeHost;
    public PackageList(ReactNativeHost reactNativeHost) {
      this.reactNativeHost = reactNativeHost;
    }
  
    public PackageList(Application application) {
      this.reactNativeHost = null;
      this.application = application;
    }
  
    private ReactNativeHost getReactNativeHost() {
      return this.reactNativeHost;
    }
  
    private Resources getResources() {
      return this.getApplication().getResources();
    }
  
    private Application getApplication() {
      if (this.reactNativeHost == null) return this.application;
      return this.reactNativeHost.getApplication();
    }
  
    private Context getApplicationContext() {
      return this.getApplication().getApplicationContext();
    }
  
    public ArrayList&lt;ReactPackage&gt; getPackages() {
      return new ArrayList&lt;&gt;(Arrays.&lt;ReactPackage&gt;asList(
        new MainReactPackage(),
        new AsyncStoragePackage(),
        new AppCenterReactNativeAnalyticsPackage(MainApplication.this, getResources().getString(R.string.appCenterAnalytics_whenToEnableAnalytics)),
        new AppCenterReactNativeCrashesPackage(MainApplication.this, getResources().getString(R.string.appCenterCrashes_whenToSendCrashes)),
        new RNSentryPackage(),
        new SplashScreenReactPackage()
      ));
    }
  }
  </code></pre>
  
  <p>The <code>MainApplication.java</code> file is inside of <code>android/main/java/com/nfibengage/MainApplication.java</code>:</p>
  
  <pre><code>package com.nfibengage;
  
  import android.app.Application;
  import android.util.Log;
  
  import com.facebook.react.PackageList;
  import com.facebook.hermes.reactexecutor.HermesExecutorFactory;
  import com.facebook.react.bridge.JavaScriptExecutorFactory;
  import com.facebook.react.ReactApplication;
  import com.facebook.react.ReactNativeHost;
  import com.facebook.react.ReactPackage;
  import com.facebook.soloader.SoLoader;
  
  import java.util.List;
  
  public class MainApplication extends Application implements ReactApplication {
  
    private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
      @Override
      public boolean getUseDeveloperSupport() {
        return BuildConfig.DEBUG;
      }
  
      @Override
      protected List&lt;ReactPackage&gt; getPackages() {
        @SuppressWarnings("UnnecessaryLocalVariable")
        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());
        return packages;
      }
  
      @Override
      protected String getJSMainModuleName() {
        return "index";
      }
    };
  
    @Override
    public ReactNativeHost getReactNativeHost() {
      return mReactNativeHost;
    }
  
    @Override
    public void onCreate() {
      super.onCreate();
      SoLoader.init(this, /* native exopackage */ false);
    }
  }
  </code></pre>
  
  <p>I tried importing it into <code>PackageList.java</code> like so:</p>
  
  <pre><code>import com.nfibengage.MainApplication;
  </code></pre>
  
  <p>but I continue to get the same error. If anyone can walk me through where did this <code>PackageList.java</code> file come from and how do I get this working again short of just completely removing <code>appcenter-analytics</code> and <code>appcenter-crashes</code>.</p>