Jordan Lewallen
Jordan Lewallen

Reputation: 1851

How to fix missing symbols and packages for React Native App in Android Studio?

I have my app running on iOS, but I wanted to test in Android before moving forward however when I try and build in Android Studio and I get the following 4 errors:

PATH/uncvrd/MainApplication.java:14: error: cannot find symbol public class MainApplication extends ExpoApplication {
                                     ^   symbol: class ExpoApplication PATH/uncvrd/MainActivity.java:11: error: package com.uncvrd.generated does not exist import com.uncvrd.generated.DetachBuildConstants;
                           ^ PATH/uncvrd/MainActivity.java:12: error: package com.uncvrd.experience does not exist import com.uncvrd.experience.DetachActivity;
                            ^ PATH/uncvrd/MainActivity.java:14: error: cannot find symbol public class MainActivity extends DetachActivity {
                                  ^   symbol: class DetachActivity 4 errors :app:compileDevDebugJavaWithJavac FAILED

I came from CRNA and ejected to ExpoKit. Here's my MainApplication.java:

package com.uncvrd;

import com.facebook.react.ReactPackage;

import java.util.Arrays; import java.util.List;

// Needed for `react-native link` // import com.facebook.react.ReactApplication; import com.geektime.rnonesignalandroid.ReactNativeOneSignalPackage; import com.inprogress.reactnativeyoutube.ReactNativeYouTube; import com.oblador.vectoricons.VectorIconsPackage;

public class MainApplication extends ExpoApplication {

  @Override   public boolean isDebug() {
    return BuildConfig.DEBUG;   }

  // Needed for `react-native link`   public List<ReactPackage> getPackages() {
    return Arrays.<ReactPackage>asList(
        // Add your own packages here!
        // TODO: add native modules!

        // Needed for `react-native link`
        // new MainReactPackage(),
            new ReactNativeOneSignalPackage(),
            new ReactNativeYouTube(),
            new VectorIconsPackage()
    );   }

  @Override   public String gcmSenderId() {
    return getString(R.string.gcm_defaultSenderId);   }

  @Override   public boolean shouldUseInternetKernel() {
    return BuildVariantConstants.USE_INTERNET_KERNEL;   } }

And my MainActivity.java:

package com.uncvrd;

import android.os.Bundle;

import com.facebook.react.ReactPackage;

import java.util.ArrayList; import java.util.Arrays; import java.util.List;

import com.uncvrd.generated.DetachBuildConstants; import com.uncvrd.experience.DetachActivity;

public class MainActivity extends DetachActivity {

  @Override   public String publishedUrl() {
    return "exp://exp.host/@jlewallen18/UNCVRD";   }

  @Override   public String developmentUrl() {
    return DetachBuildConstants.DEVELOPMENT_URL;   }

  @Override   public List<String> sdkVersions() {
    return new ArrayList<>(Arrays.asList("26.0.0"));   }

  @Override   public List<ReactPackage> reactPackages() {
    return ((MainApplication) getApplication()).getPackages();   }

  @Override   public boolean isDebug() {
    return BuildConfig.DEBUG;   }

  @Override   public Bundle initialProps(Bundle expBundle) {
    // Add extra initialProps here
    return expBundle;   } }

What's the best way to fix these errors? Please let me know if you need more information

Upvotes: 2

Views: 1842

Answers (1)

GentryRiggen
GentryRiggen

Reputation: 858

Our team had the generated file git ignored but you need it. If you add this to /android/app/src/main/java/host/exp/exponent/generated/DetachBuildConstants.java does that help?

package host.exp.exponent.generated;

public class DetachBuildConstants {

  public static final String DEVELOPMENT_URL = "";

}

Upvotes: 6

Related Questions