skip to Main Content

I was running this rn app without issues. I had to expo eject. After expo eject, I can’t get the project to run.

So when I run yarn android build fails with this error.

J:WORKCURRENTREACT_NATIVEmoot-RNmyeject_trymoot-RNandroidappsrcmainjavahamootappMainActivity.java:22: error: package R does not exist
    setTheme(R.style.AppTheme);
              ^
J:WORKCURRENTREACT_NATIVEmoot-RNmyeject_trymoot-RNandroidappsrcmainjavahamootappMainActivity.java:42: error: cannot find symbol
    return new ReactActivityDelegateWrapper(this, BuildConfig.IS_NEW_ARCHITECTURE_ENABLED, new DefaultReactActivityDelegate(
                                                  ^
  symbol:   variable BuildConfig
  location: class MainActivity
J:WORKCURRENTREACT_NATIVEmoot-RNmyeject_trymoot-RNandroidappsrcmainjavahamootappMainApplication.java:29: error: cannot find symbol
        return BuildConfig.DEBUG;
               ^
  symbol: variable BuildConfig
J:WORKCURRENTREACT_NATIVEmoot-RNmyeject_trymoot-RNandroidappsrcmainjavahamootappMainApplication.java:48: error: cannot find symbol
        return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
               ^
  symbol: variable BuildConfig
J:WORKCURRENTREACT_NATIVEmoot-RNmyeject_trymoot-RNandroidappsrcmainjavahamootappMainApplication.java:53: error: cannot find symbol
        return BuildConfig.IS_HERMES_ENABLED;
               ^
  symbol: variable BuildConfig
J:WORKCURRENTREACT_NATIVEmoot-RNmyeject_trymoot-RNandroidappsrcmainjavahamootappMainApplication.java:66: error: cannot find symbol
    if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
        ^
  symbol:   variable BuildConfig
  location: class MainApplication
6 errors

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
java.lang.StackOverflowError (no error message)

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================

So it seems the R and BuildConfig is not imported in MainApplication.java file. So I added this manually.

import com.facebook.react.BuildConfig;

After I run yarn android again, now I get this error.

A problem occurred configuring project ':react-native-gradle-plugin'.
> java.util.concurrent.ExecutionException: org.gradle.api.GradleException: Failed to create Jar file C:UsersUser.gradlecachesjars-9196b729407d7fbb2907378f4b4c34b5akotlin-gradle-plugin-1.6.10.jar.

I also saw something about package name issues.

This is package name in my manifest->>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="ha.mootapp" xmlns:tools="http://schemas.android.com/tools">

and app/build.gradle ->>

android {
    ndkVersion rootProject.ext.ndkVersion

    compileSdkVersion rootProject.ext.compileSdkVersion

    namespace "com.moot"
    defaultConfig {
        applicationId 'ha.mootapp'
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0.1"
    }

Does anyone know what’s wrong?

2

Answers


  1. Chosen as BEST ANSWER

    It seems there is a issue with expo version 48. There is a github issues>https://github.com/expo/expo/issues/21750 I downgraded to 45 and build was fine.


  2. Try removing the expo-cli dependency: yarn remove expo-cli

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search