Cannot find symbol ExpoApplication in MainApplication.java

#1

Hi! 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 getPackages() {
return Arrays.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 sdkVersions() {
return new ArrayList<>(Arrays.asList(“26.0.0”));
}

@Override
public List 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

#2

You use exp detach or RN eject?

#3

Hi @jlewallen18 - it looks like you’ve changed the name of the ExpoKit java package from host.exp.exponent to com.uncvrd. This is likely what’s causing your issues, as certain parts of Expo’s code depend on that exact package name.

If you are trying to change your application package name, you can do that simply by editing your android/app/build.gradle and changing the value at:

  defaultConfig {
    applicationId 'host.exp.exponent' // -> 'com.uncvrd'

There is no need to change the actual java package name or folder structure.

Hope that helps! Let us know if you continue to run into issues.

1 Like
#4

@esamelson yes renaming was the culprit! I tried using a package called react-native-rename but thanks for the simplistic fix. I reverted to before the rename and it compiles :slight_smile:

1 Like
closed #5

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.