Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expo build failed / SDK 48 #21784

Closed
MylchenkoAlexandr opened this issue Mar 20, 2023 · 72 comments
Closed

Expo build failed / SDK 48 #21784

MylchenkoAlexandr opened this issue Mar 20, 2023 · 72 comments
Labels
CLI Versioned Expo CLI -- `npx expo start` incomplete issue: missing or invalid repro A minimal reproducible example is required for most issues

Comments

@MylchenkoAlexandr
Copy link

Summary

Build failed after update to SDK 48 (from SDK 46).
No any errors while application running in development mode.
Any help?

What platform(s) does this occur on?

Android

SDK Version

48

Environment

System:
OS: macOS 13.2.1
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.16.0 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 8.11.0 - /usr/local/bin/npm
IDEs:
Xcode: /undefined - /usr/bin/xcodebuild
npmPackages:
@expo/metro-config: ^0.5.2 => 0.5.2
@expo/webpack-config: ^18.0.1 => 18.0.1
expo: ^48.0.0 => 48.0.8
react: 18.2.0 => 18.2.0
react-dom: 18.2.0 => 18.2.0
react-native: 0.71.3 => 0.71.3
react-native-web: ~0.18.11 => 0.18.12
Expo Workflow: managed

Minimal reproducible example

package.json

{
"name": "eshka.client",
"version": "1.0.4",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start --no-dev --minify",
"develop": "expo start --clear",
"build:android": "eas build --platform android",
"build:apk": "eas build --platform android --profile stage",
"build:ios": "eas build --platform ios"
},
"dependencies": {
"@ant-design/react-native": "^5.0.0",
"@expo/metro-config": "^0.5.2",
"@expo/webpack-config": "^18.0.1",
"@googlemaps/polyline-codec": "^1.0.28",
"@react-native-async-storage/async-storage": "1.17.11",
"@react-native-community/datetimepicker": "6.7.3",
"@react-native-community/netinfo": "9.3.7",
"axios": "^0.27.2",
"babel-plugin-inline-import": "^3.0.0",
"base-64": "^1.0.0",
"centrifuge": "2.7.6",
"deprecated-react-native-prop-types": "^4.0.0",
"eas-cli": "^3.7.2",
"email-validator": "^2.0.4",
"expo": "^48.0.0",
"expo-app-loading": "~2.1.0",
"expo-asset": "~8.9.1",
"expo-camera": "~13.2.1",
"expo-cli": "5.5.0",
"expo-env-info": "^1.0.5",
"expo-file-system": "~15.2.2",
"expo-font": "~11.1.1",
"expo-image-picker": "~14.1.1",
"expo-localization": "~14.1.1",
"expo-location": "~15.1.1",
"expo-status-bar": "~1.4.4",
"expo-task-manager": "~11.1.1",
"expo-tracking-transparency": "~3.0.3",
"expo-updates": "~0.16.3",
"http-status-codes": "^2.2.0",
"i18n-js": "^4.2.0",
"lodash": "^4.17.21",
"md5": "^2.3.0",
"moment": "^2.29.4",
"patch-package": "^6.5.1",
"prop-types": "^15.8.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.71.3",
"react-native-confirmation-code-input": "^1.0.4",
"react-native-gesture-handler": "~2.9.0",
"react-native-keyboard-aware-scroll-view": "^0.9.5",
"react-native-maps": "1.3.2",
"react-native-masked-text": "^1.13.0",
"react-native-modal": "^13.0.1",
"react-native-safe-area-context": "4.5.0",
"react-native-snap-carousel": "^3.9.1",
"react-native-sortable-list": "^0.0.25",
"react-native-svg": "13.4.0",
"react-native-svg-transformer": "^0.14.3",
"react-native-svg-uri": "^1.2.3",
"react-native-ultimate-listview": "^3.3.0",
"react-native-web": "~0.18.11",
"react-native-webview": "11.26.0",
"react-redux": "^8.0.2",
"react-router-native": "~6.3.0",
"redux": "^4.2.0",
"redux-saga": "^1.1.3"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@expo/metro-config": "^0.5.2",
"@expo/webpack-config": "^18.0.1",
"@types/lodash": "^4.14.182",
"@types/react": "~18.0.27",
"@types/react-native": "~0.69.1",
"babel-plugin-inline-import": "^3.0.0",
"react-native-svg-transformer": "^0.14.3",
"typescript": "^4.9.4"
},
"private": true
}

Stacktrace (if a crash is involved)

[stderr] /home/expo/workingdir/build/android/app/src/main/java/com/eshka2k34/client/MainActivity.java:19: error: package R does not exist
[stderr]     setTheme(R.style.AppTheme);
[stderr]               ^
[stderr] /home/expo/workingdir/build/android/app/src/main/java/com/eshka2k34/client/MainActivity.java:39: error: cannot find symbol
[stderr]     return new ReactActivityDelegateWrapper(this, BuildConfig.IS_NEW_ARCHITECTURE_ENABLED, new DefaultReactActivityDelegate(
[stderr] 
                                                  ^
[stderr]   symbol:   variable BuildConfig
[stderr]   location: class MainActivity
[stderr] 
/home/expo/workingdir/build/android/app/src/main/java/com/eshka2k34/client/MainApplication.java:26: error: cannot find symbol
[stderr]         return BuildConfig.DEBUG;
[stderr]                ^
[stderr]   symbol: variable BuildConfig
[stderr] /home/expo/workingdir/build/android/app/src/main/java/com/eshka2k34/client/MainApplication.java:45: error: cannot find symbol
[stderr]         return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
[stderr]                ^
[stderr]   symbol: variable BuildConfig
[stderr] /home/expo/workingdir/build/android/app/src/main/java/com/eshka2k34/client/MainApplication.java:50: error: cannot find symbol
[stderr]         return BuildConfig.IS_HERMES_ENABLED;
[stderr]                ^
[stderr]   symbol: variable BuildConfig
[stderr] /home/expo/workingdir/build/android/app/src/main/java/com/eshka2k34/client/MainApplication.java:63: error: cannot find symbol
[stderr]     if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
[stderr]         ^
[stderr]   symbol:   variable BuildConfig
[stderr]   location: class MainApplication
[stderr] /home/expo/workingdir/build/android/app/src/main/java/com/eshka2k34/client/MainApplication.java:63: error: illegal parenthesized expression
[stderr]     if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
[stderr]        ^
[stderr] /home/expo/workingdir/build/android/app/src/main/java/com/eshka2k34/client/MainApplication.java:67: error: cannot find symbol
[stderr]     ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
[stderr]     ^
[stderr]   symbol:   variable ReactNativeFlipper
[stderr]   location: class MainApplication
[stderr] 8 errors
w: Detected multiple Kotlin daemon sessions at build/kotlin/sessions
[stderr] FAILURE: Build completed with 2 failures.
[stderr] 1: Task failed with an exception.
[stderr] -----------
[stderr] * What went wrong:
[stderr] Execution failed for task ':app:compileReleaseJavaWithJavac'.
[stderr] > Compilation failed; see the compiler error output for details.
[stderr] * Try:
[stderr] > Run with --stacktrace option to get the stack trace.
[stderr] > Run with --info or --debug option to get more log output.
[stderr] > Run with --scan to get full insights.
[stderr] ==============================================================================
[stderr] 2: Task failed with an exception.
[stderr] -----------
[stderr] * What went wrong:
[stderr] java.lang.StackOverflowError (no error message)
[stderr] * Try:
[stderr] > Run with --stacktrace option to get the stack trace.
[stderr] > Run with --info or --debug option to get more log output.
[stderr] > Run with --scan to get full insights.
[stderr] 
==============================================================================
[stderr] * Get more help at https://help.gradle.org
[stderr] **BUILD FAILED in 5m 47s**
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings
Execution optimizations have been disabled for 6 invalid unit(s) of work during this build to ensure correctness.
Please consult deprecation warnings for more details.
938 actionable tasks: 938 executed
Error: Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.
@MylchenkoAlexandr MylchenkoAlexandr added CLI Versioned Expo CLI -- `npx expo start` needs validation Issue needs to be validated labels Mar 20, 2023
@expo-bot expo-bot removed the needs validation Issue needs to be validated label Mar 20, 2023
@IAmCoder
Copy link

IAmCoder commented Mar 21, 2023

See: #21477 (comment)

You can bypass this by adding a config plugin that changes the namespaces under ./pluigins/withAndroidNamespace.js:

const { withAppBuildGradle } = require('@expo/config-plugins');

const withAndroidNamespace = (config) => {
    return withAppBuildGradle(config, (config) => {
        const buildGradle = config.modResults.contents;
        const namespace = config.android.package.toString();
        const newContents = buildGradle.replace(
            /namespace (.*)\n/,
            `namespace '${namespace}'\n`
        );
        config.modResults.contents = newContents;
        console.log(`withAndroidNamespace: change namespace to ${namespace}`);
        return config;
    });
};

module.exports = withAndroidNamespace;

And adding it to the plugins section in app.json:

{
  ...
  plugins: ['./plugins/withAndroidNamespace']
}

@MylchenkoAlexandr
Copy link
Author

#21477 (comment)

No, it not work ,(

[stderr] /home/expo/workingdir/build/android/app/src/main/java/com/eshka2k23/driver/MainApplication.java:67: error: cannot find symbol
[stderr]     ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
[stderr]     ^
[stderr]   symbol:   variable ReactNativeFlipper
[stderr]   location: class MainApplication
[stderr] 1 error
w: Detected multiple Kotlin daemon sessions at build/kotlin/sessions
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings
Execution optimizations have been disabled for 6 invalid unit(s) of work during this build to ensure correctness.
Please consult deprecation warnings for more details.
968 actionable tasks: 968 executed
[stderr] FAILURE: Build completed with 2 failures.
[stderr] 1: Task failed with an exception.
[stderr] -----------
[stderr] * What went wrong:
[stderr] Execution failed for task ':app:compileReleaseJavaWithJavac'.
[stderr] > Compilation failed; see the compiler error output for details.
[stderr] * Try:
[stderr] > Run with --stacktrace option to get the stack trace.
[stderr] > Run with --info or --debug option to get more log output.
[stderr] > Run with --scan to get full insights.
[stderr] ==============================================================================
[stderr] 2: Task failed with an exception.
[stderr] -----------
[stderr] * What went wrong:
[stderr] java.lang.StackOverflowError (no error message)
[stderr] * Try:
[stderr] > Run with --stacktrace option to get the stack trace.
[stderr] > Run with --info or --debug option to get more log output.
[stderr] > Run with --scan to get full insights.
[stderr] ==============================================================================
[stderr] * Get more help at https://help.gradle.org
[stderr] BUILD FAILED in 8m 30s
Error: Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.

@IAmCoder
Copy link

Well, now the package R does not exist errors are gone.

For the ReactNativeFlipper error you will need this patch:
main...iegik:expo:patch-3

Alternatively you can downgrade to 47: expo upgrade 47.

@sumagowda
Copy link

sumagowda commented Mar 21, 2023

I deleted android build folder in the root directory & then tried eas build --platform android that seemed to resolve this error.

@MylchenkoAlexandr
Copy link
Author

I deleted android build folder in the root directory & then tried eas build --platform android that seemed to resolve this error.

I dont have "android" folder. I use clean Expo project and i not use any gradle config files.

@MylchenkoAlexandr
Copy link
Author

MylchenkoAlexandr commented Mar 21, 2023

Well, now the package R does not exist errors are gone.

For the ReactNativeFlipper error you will need this patch: main...iegik:expo:patch-3

Alternatively you can downgrade to 47: expo upgrade 47.

I downgrade to SDK 47 and ...get new problems ,(
Expo.IO - is deamn hell! Today it work, tomorrow it don't work ,(

Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). Module has not been registered as callable. Registered callable JavaScript modules (n = 11): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, JSDevSupportModule, HMRClient, RCTEventEmitter.
        A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:95:17 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:141:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:39 in handleError
at node_modules/expo/build/errors/ExpoErrorManager.js:25:19 in errorHandler
at node_modules/expo/build/errors/ExpoErrorManager.js:30:24 in <anonymous>
at node_modules/@react-native/polyfills/error-guard.js:49:36 in ErrorUtils.reportFatalError

Invariant Violation: ViewPropTypes has been removed from React Native. Migrate to ViewPropTypes exported from 'deprecated-react-native-prop-types'.
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:95:17 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:141:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:39 in handleError
at node_modules/expo/build/errors/ExpoErrorManager.js:25:19 in errorHandler
at node_modules/expo/build/errors/ExpoErrorManager.js:30:24 in <anonymous>
at node_modules/@react-native/polyfills/error-guard.js:49:36 in ErrorUtils.reportFatalError
at node_modules/metro-runtime/src/polyfills/require.js:237:40 in guardedLoadModule
at http://192.168.1.27:19000/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false&strict=false&minify=false:null in global code

Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). Module has not been registered as callable. Registered callable JavaScript modules (n = 11): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, JSDevSupportModule, HMRClient, RCTEventEmitter.
        A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:95:17 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:141:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:39 in handleError
at node_modules/expo/build/errors/ExpoErrorManager.js:25:19 in errorHandler
at node_modules/expo/build/errors/ExpoErrorManager.js:30:24 in <anonymous>
at node_modules/@react-native/polyfills/error-guard.js:49:36 in ErrorUtils.reportFatalError

@MylchenkoAlexandr
Copy link
Author

Well, now the package R does not exist errors are gone.

For the ReactNativeFlipper error you will need this patch: main...iegik:expo:patch-3

Alternatively you can downgrade to 47: expo upgrade 47.

Please hint me - how it patch? I tried to find [ /node_modules/expo/docs/public/static/diffs/expo-android.diff ] - but he's not there ,(( Or am I doing it wrong?

@wilkuintheair
Copy link

What worked for me was to make sure that the namespace in android/app/build.gradle was correct and then run ./gradlew clean and then run the android app again.

For some reason the namespace generated with expo prebuild was wrong.

I.e. My MainApplication.java file was located in com/company/app folder so the namespace should be com.company.app.

@eGeniusAcademic
Copy link

Same issue for me, any solution till now?

1 similar comment
@eGeniusAcademic
Copy link

Same issue for me, any solution till now?

@Carlosreyesk
Copy link

Same here

@MylchenkoAlexandr
Copy link
Author

What worked for me was to make sure that the namespace in android/app/build.gradle was correct and then run ./gradlew clean and then run the android app again.

For some reason the namespace generated with expo prebuild was wrong.

I.e. My MainApplication.java file was located in com/company/app folder so the namespace should be com.company.app.

What about developers who not use gradle? I seems - SDK 48 from a box (as is) should work without any fixes?!!! It may work correctly by default as (for example) SDK 46! Now any build in EXPO is - paid! 1$ - Android and 2$ - iOS, ...How its solve the problem? ))) Maybe this will up the quality of the EXPO in the future.

@JaLe29
Copy link

JaLe29 commented Mar 28, 2023

same problems in our project. We can't release a new version. It is a critical problem for my team.

@seyicoded
Copy link

Alternatively you can downgrade to 47: expo upgrade 47.

Yes, then after this adjustment make sure your

"resolutions": {
"@expo/config-plugins": "~6.0.0",
"@expo/prebuild-config": "~6.0.0",
"expo-modules-autolinking": "1.1.0"
}

is upto date or atleast this version, then run expo doctor to make sure everything is okay from expo end

@MylchenkoAlexandr
Copy link
Author

same problems in our project. We can't release a new version. It is a critical problem for my team.

My SDK 48 build work good! I am build and submit application to the Play Market and Google Store! Two weeks after I published programs in the Market/Store - my client asked to make minor changes in the color scheme. I change two variable values ...and I could no longer build the program in the cloud. The original (submited/published) version also crashed too.

@geeron
Copy link
Contributor

geeron commented Mar 28, 2023

Same here

@MylchenkoAlexandr
Copy link
Author

MylchenkoAlexandr commented Mar 28, 2023

expo downgrade 47
expo doctor

It make me another problems.
I solve all this problems by downgrade to SDK 46.

The history:

  1. Half a year ago i am start with SDK 45 (crossplafrom application for iOS and Adroid) ;
  2. Month ago - EXPO.IO deprecate SDK 45 ;
  3. I am upgrade application (from SDK 45) to SDK 48 and successfuly submit/publish it to Apple Strore and Google Play ;
  4. My client asked me to change the color scheme - I changed a value in variables, but the application wasn't building anymore ;
  5. I downgrade from SDK 48 to SDK 46... and oh thank god... This nightmare was over.

@pnadj
Copy link

pnadj commented Mar 29, 2023

It's very strange that when I don't build locally its fine, but when i add the --local tag its suddenly broken 🤔

@hotaryuzaki
Copy link

I dont have "android" folder. I use clean Expo project and i not use any gradle config files.

wow.. so the error already occured from the default app??

@hotaryuzaki
Copy link

hotaryuzaki commented Mar 30, 2023

What worked for me was to make sure that the namespace in android/app/build.gradle was correct and then run ./gradlew clean and then run the android app again.

For some reason the namespace generated with expo prebuild was wrong.

I.e. My MainApplication.java file was located in com/company/app folder so the namespace should be com.company.app.

you are right, very strange expo give a wrong namespace.

but the difference is i'm using the old expo eject (it still works perfectly), not expo prebuild, after I upgraded from version 47.
So changing it to the correct namespace fixed the debug build.

===

Oh, I have found that ReactNativeFlipper.java in the release folder is created with the wrong package name.
do not forget to change it too

@MylchenkoAlexandr
Copy link
Author

I dont have "android" folder. I use clean Expo project and i not use any gradle config files.

wow.. so the error already occured from the default app??

yes

@dzpincus
Copy link

Same problem. Anyone been able to find a solution?

@JaLe29
Copy link

JaLe29 commented Mar 31, 2023

I dont have "android" folder. I use clean Expo project and i not use any gradle config files.

wow.. so the error already occured from the default app??

yes

Same problem, no android folder. Just clean expo project with all default files.

@andrebeolchi
Copy link

What worked for me was to make sure that the namespace in android/app/build.gradle was correct and then run ./gradlew clean and then run the android app again.

For some reason the namespace generated with expo prebuild was wrong.

I.e. My MainApplication.java file was located in com/company/app folder so the namespace should be com.company.app.

It worked!! I created my app with the package name "app.name" and for some reason the namespace was "com.name", it worked as soon as I changed the "com" to "app"

@ozdemiremrah
Copy link

I faced same error.

Expo is generated wrong namespace.
I fixed the problem following this is steps;

  1. Check your npm project name in package.json file.
  2. Check your app.json file, iOS bundleIdentifier and android package paramters must be same as your package.json name with prefix com.

For Example package.json

{
  "name": "foo.bar",
  ...

and app.json

...
 "ios": {
      "supportsTablet": true,
      "bundleIdentifier": "com.foo.bar"....
"android": {
      "package": "com.foo.bar",....

It fixed my problem.

@AnthonyRRRR
Copy link

AnthonyRRRR commented Apr 6, 2023

Removed expo-cli from dependencies, it worked for me

@Jo75020
Copy link

Jo75020 commented Apr 6, 2023

Removed expo-cli from dependencies, it worked for me

Very niice, This worked for me.

@mphill
Copy link

mphill commented Jun 19, 2023

I was able to resolve this issue by running all commands using local package instead of global one i.e.:

  • npx expo prebuild instead of expo prebuild
  • npx expo run:android instead of expo run:android

Wow! Thanks! That's the best workaround ever. Was totally expecting to have to edit source java files...

@dvthust
Copy link

dvthust commented Jun 24, 2023

#21477 (comment)

No, it not work ,(

[stderr] /home/expo/workingdir/build/android/app/src/main/java/com/eshka2k23/driver/MainApplication.java:67: error: cannot find symbol
[stderr]     ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
[stderr]     ^
[stderr]   symbol:   variable ReactNativeFlipper
[stderr]   location: class MainApplication
[stderr] 1 error
w: Detected multiple Kotlin daemon sessions at build/kotlin/sessions
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings
Execution optimizations have been disabled for 6 invalid unit(s) of work during this build to ensure correctness.
Please consult deprecation warnings for more details.
968 actionable tasks: 968 executed
[stderr] FAILURE: Build completed with 2 failures.
[stderr] 1: Task failed with an exception.
[stderr] -----------
[stderr] * What went wrong:
[stderr] Execution failed for task ':app:compileReleaseJavaWithJavac'.
[stderr] > Compilation failed; see the compiler error output for details.
[stderr] * Try:
[stderr] > Run with --stacktrace option to get the stack trace.
[stderr] > Run with --info or --debug option to get more log output.
[stderr] > Run with --scan to get full insights.
[stderr] ==============================================================================
[stderr] 2: Task failed with an exception.
[stderr] -----------
[stderr] * What went wrong:
[stderr] java.lang.StackOverflowError (no error message)
[stderr] * Try:
[stderr] > Run with --stacktrace option to get the stack trace.
[stderr] > Run with --info or --debug option to get more log output.
[stderr] > Run with --scan to get full insights.
[stderr] ==============================================================================
[stderr] * Get more help at https://help.gradle.org
[stderr] BUILD FAILED in 8m 30s
Error: Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.

added new plugin such as

const { withMainApplication } = require('@expo/config-plugins');
const withoutAndroidFlipper = config => {
  return withMainApplication(config, async config => {
    const mainApplication = config.modResults.contents;
    const newContents = mainApplication?.replace(
      "ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager());",
      "",
    );
    config.modResults.contents = newContents;
    return config;
  });
};
module.exports = withoutAndroidFlipper;

and add the link to it inside the app.json "plugins": ["./plugins/withoutAndroidFlipper"]

Seems like expo team forgot to remove the flipper from the assembled version of the app

It's worked for me. Thanks !

@diamondrarktvo
Copy link

sue by running all commands using local package instead of global one i.e.:

* `npx expo prebuild` instead of `expo prebuild`

* `npx expo run:android` instead of `expo run:android`

This is the best solution

@mauricedoepke
Copy link

I have the same issue in sdk 49 even though I don't have the global expo-cli installed

@shahzaib803
Copy link

I have the same issue in SDK 48.0.18
None of the above solutions worked!

@znanick
Copy link

znanick commented Jul 10, 2023

None of the above solutions worked.
Expo 48.0.18

@nawedfarooque
Copy link

+1 None of the above solutions worked :(

@nawedfarooque
Copy link

I got it. This helps for me:

  • downgrade to expo 47.0.0.
  • check and fix dependencies with npx expo-doctor
  • delete android & iOS folder (in case you did prebuild before)
  • delete package-lock.json
  • delete npm folder with rm -rf node_modules

now it should be clean and you can build your package with

  • npx eas build

@kylegwalsh
Copy link

This issue was a journey. I think I finally got everything working the way I needed. I'll list my steps below.

I basically ran into two main issues:

  1. The namespace in android/app/build.gradle was being generated incorrectly (it seemingly references the app name rather than the package ID. For example, my name was "AppName (env)" and my package was "com.app.env". In the build.gradle, it was using namespace "com.appnameenv" (seems like the app name with parenthesis and spaces removed). This should have been com.app.env and caused things not to load correctly.
  2. The release version of ReactNativeFlipper.java is created in the wrong folder AND has the wrong package name. For example, it was being generated in android/app/src/release/java/com/appnameenv/ReactNativeFlipper.java and used package name com.appnameenv. Both of these seem to be based on the app name like above, but it should have been generated as android/app/src/release/java/com/app/env/ReactNativeFlipper.java with package name com.app.env.

It's important to note that the second issue only appears on release builds (I use expo to create builds in the cloud). The first issue impacts dev builds and release builds.

In order to fix this, I referenced several of the other fixes on this thread to create a single expo plugin that:

  1. Fixes the namespace in the build.gradle
  2. Removes ReactNativeFlipper from the MainApplication.java (I didn't need it)

Inside my withAndroidExpoFix.js file:

import { withAppBuildGradle, withMainApplication, createRunOncePlugin } from '@expo/config-plugins';

/**
 * This plugin is a temporary fix that is needed to fix Android builds on Expo 48.
 * There are two main issues:
 * 1. The namespace in android/app/build.gradle needs to match
 * the application id (like com.app.env), but it is set incorrectly
 * 2. The folder structure and package name in android/app/src/release/com/XXX/ReactNativeFlipper.java
 * is not created correctly
 */
const withAndroidExpoFix = (config) => {
  // Fix the namespace in android/app/build.gradle
  config = withAppBuildGradle(config, (config) => {
    const buildGradle = config.modResults.contents;
    const namespace = config?.android?.package?.toString?.();
    const newContents = buildGradle.replace(/namespace (.*)\n/, `namespace '${namespace}'\n`);
    config.modResults.contents = newContents;
    console.log(`[withAndroidExpoFix] Change build.gradle namespace to ${namespace}`);

    return config;
  });

  // Remove ReactNativeFlipper
  config = withMainApplication(config, async (config) => {
    const mainApplication = config.modResults.contents;
    const newContents = mainApplication?.replace(
      'ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager());',
      ''
    );
    config.modResults.contents = newContents;
    console.log(`[withAndroidExpoFix] Remove ReactNativeFlipper`);

    return config;
  });

  return config;
};

export default createRunOncePlugin(withAndroidExpoFix, 'withAndroidExpoFix', '1.0.0');

Inside my app.config.js file:

plugins: [
     // Had to create a custom plugin to fix an Android issue on Expo 48
     './plugins/withAndroidExpoFix'
]

After testing, I've been able to run it locally and the release build finally succeeded. Hope this helps anyone else who is dealing with both issues.

@iuribtt
Copy link

iuribtt commented Jul 27, 2023

Removed expo-cli from dependencies, it worked for me

For me too. I remove locally and globally. To use androidSdk 49.0.0.

I just remove the expo-cli from the project and globally. i.e:

npm uninstal expo-cli
npm uninstal -g expo-cli

Now I run expo start. And type 's' for Expo Go, for example.

@mahmoud16h
Copy link

Inside my withAndroidExpoFix.js file:

import { withAppBuildGradle, withMainApplication, createRunOncePlugin } from '@expo/config-plugins';

/**
 * This plugin is a temporary fix that is needed to fix Android builds on Expo 48.
 * There are two main issues:
 * 1. The namespace in android/app/build.gradle needs to match
 * the application id (like com.app.env), but it is set incorrectly
 * 2. The folder structure and package name in android/app/src/release/com/XXX/ReactNativeFlipper.java
 * is not created correctly
 */
const withAndroidExpoFix = (config) => {
  // Fix the namespace in android/app/build.gradle
  config = withAppBuildGradle(config, (config) => {
    const buildGradle = config.modResults.contents;
    const namespace = config?.android?.package?.toString?.();
    const newContents = buildGradle.replace(/namespace (.*)\n/, `namespace '${namespace}'\n`);
    config.modResults.contents = newContents;
    console.log(`[withAndroidExpoFix] Change build.gradle namespace to ${namespace}`);

    return config;
  });

  // Remove ReactNativeFlipper
  config = withMainApplication(config, async (config) => {
    const mainApplication = config.modResults.contents;
    const newContents = mainApplication?.replace(
      'ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager());',
      ''
    );
    config.modResults.contents = newContents;
    console.log(`[withAndroidExpoFix] Remove ReactNativeFlipper`);

    return config;
  });

  return config;
};

export default createRunOncePlugin(withAndroidExpoFix, 'withAndroidExpoFix', '1.0.0');

so i'm currently giving this a go, i'm on expo 49 and have been experiencing the same issues about, it's a joke.

ANy idea when expo are going to fix this?

@HaimAbeles
Copy link

I have the same issue in sdk 49 even though I don't have the global expo-cli installed

any solution?

@NilsBaumgartner1994
Copy link

Still facing same problems

@HaimAbeles
Copy link

Still facing same problems

I solved the problem, you need to use the new expo-cli commands, if you want help, tomorrow I will be able to answer in more detail what is required for the upgrade

@NilsBaumgartner1994
Copy link

NilsBaumgartner1994 commented Aug 28, 2023 via email

@HaimAbeles
Copy link

I am on expo 49 (latest?) and the problem also occurs. HaimAbeles @.***> schrieb am Mo. 28. Aug. 2023 um 21:17:

I'm also on the latest (49), the solution was a bit of configuration in app.json + using the new expo cli commands

@NilsBaumgartner1994
Copy link

NilsBaumgartner1994 commented Aug 28, 2023 via email

@HaimAbeles
Copy link

Ok, I'll check it out. HaimAbeles @.***> schrieb am Mo. 28. Aug. 2023 um 21:30:

this is the solution:
npm i expo-cli -g
and now you need to use the new expo cli commands
npx expo-cli upgrade 49
and add to your app.json or app.config.js file this configuration:
updates: { url: "https://u.expo.dev/{YOUR_PROJECT_ID}", useClassicUpdates: true, }

@EvanBacon EvanBacon added the incomplete issue: missing or invalid repro A minimal reproducible example is required for most issues label Aug 30, 2023
@expo-bot
Copy link
Collaborator

Hi there! It looks like your issue requires a minimal reproducible example, but it is invalid or absent. Please prepare such an example and share it in a new issue.

The best way to get attention to your issue is to provide a clean and easy way for a developer to reproduce the issue on their own machine. Please do not provide your entire project, or a project with more code than is necessary to reproduce the issue.

A side benefit of going through the process of narrowing down the minimal amount of code needed to reproduce the issue is that you may get lucky and discover that the bug is due to a mistake in your application code that you can quickly fix on your own.

Resources

Common concerns

"I've only been able to reproduce it in private, proprietary code"

You may not have spent enough time narrowing down the root cause of the issue. Try out the techniques discussed in this manual debugging guide to learn how to isolate the problem from the rest of your codebase.

"I didn't have time to create one"

That's understandable, it can take some time to prepare. We ask that you hold off on filing an issue until you are able to fully complete the required fields in the issue template.

"You can reproduce it by yourself by creating a project and following these steps"

This is useful knowledge, but it's still valuable to have the resulting project that is produced from running the steps, where you have verified you can reproduce the issue.

@jinkange
Copy link

jinkange commented Oct 2, 2023

  1. delete node_modules
  2. npm i
  3. try again
    im working

@JuniorFixHow
Copy link

What worked for me was to make sure that the namespace in android/app/build.gradle was correct and then run ./gradlew clean and then run the android app again.

For some reason the namespace generated with expo prebuild was wrong.

I.e. My MainApplication.java file was located in com/company/app folder so the namespace should be com.company.app.

Your are a genius. U saved my life

@ferologics
Copy link
Contributor

what a clown fiesta

@ARIARCHI-MZ
Copy link

ARIARCHI-MZ commented Nov 29, 2023

hi, i have the same problem with Expo 48 yarn build android, it failed with Gradle build failed with unknown error and Code 1
also the console log in expo is
What went wrong:
Execution failed for task ':app:compileReleaseJavaWithJavac'.

  • What went wrong:
    java.lang.StackOverflowError (no error message)
    does anyone find a solution ?

I contacted with expo support team
and this is the result that worked. i will write it that if anyone fell in the same problem follows it
the main issue is written in logs of expo build app failure
legacy expo-cli that is not supported with Node+17
( you cant downgrade expo to lower version , you might build the app but can not deploy on Google Store with its new rules)
Then you have to
remove expo-cli in global and local then start using
(npx expo [command]).

@Nxtra
Copy link

Nxtra commented Jan 30, 2024

#21477 (comment)

No, it not work ,(

[stderr] /home/expo/workingdir/build/android/app/src/main/java/com/eshka2k23/driver/MainApplication.java:67: error: cannot find symbol
[stderr]     ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
[stderr]     ^
[stderr]   symbol:   variable ReactNativeFlipper
[stderr]   location: class MainApplication
[stderr] 1 error
w: Detected multiple Kotlin daemon sessions at build/kotlin/sessions
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings
Execution optimizations have been disabled for 6 invalid unit(s) of work during this build to ensure correctness.
Please consult deprecation warnings for more details.
968 actionable tasks: 968 executed
[stderr] FAILURE: Build completed with 2 failures.
[stderr] 1: Task failed with an exception.
[stderr] -----------
[stderr] * What went wrong:
[stderr] Execution failed for task ':app:compileReleaseJavaWithJavac'.
[stderr] > Compilation failed; see the compiler error output for details.
[stderr] * Try:
[stderr] > Run with --stacktrace option to get the stack trace.
[stderr] > Run with --info or --debug option to get more log output.
[stderr] > Run with --scan to get full insights.
[stderr] ==============================================================================
[stderr] 2: Task failed with an exception.
[stderr] -----------
[stderr] * What went wrong:
[stderr] java.lang.StackOverflowError (no error message)
[stderr] * Try:
[stderr] > Run with --stacktrace option to get the stack trace.
[stderr] > Run with --info or --debug option to get more log output.
[stderr] > Run with --scan to get full insights.
[stderr] ==============================================================================
[stderr] * Get more help at https://help.gradle.org
[stderr] BUILD FAILED in 8m 30s
Error: Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.

added new plugin such as

const { withMainApplication } = require('@expo/config-plugins');
const withoutAndroidFlipper = config => {
  return withMainApplication(config, async config => {
    const mainApplication = config.modResults.contents;
    const newContents = mainApplication?.replace(
      "ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager());",
      "",
    );
    config.modResults.contents = newContents;
    return config;
  });
};
module.exports = withoutAndroidFlipper;

and add the link to it inside the app.json "plugins": ["./plugins/withoutAndroidFlipper"]

Seems like expo team forgot to remove the flipper from the assembled version of the app

This works for me. 👍
Though I have no clue what AndroidFlipper is.

@DR1988 , are there potential side effects to removing this flipper initialization?

@limonrojo-nm
Copy link

I faced same error.

Expo is generated wrong namespace. I fixed the problem following this is steps;

  1. Check your npm project name in package.json file.
  2. Check your app.json file, iOS bundleIdentifier and android package paramters must be same as your package.json name with prefix com.

For Example package.json

{
  "name": "foo.bar",
  ...

and app.json

...
 "ios": {
      "supportsTablet": true,
      "bundleIdentifier": "com.foo.bar"....
"android": {
      "package": "com.foo.bar",....

It fixed my problem.

I was similar issue in with expo 49. And this solved it!! Thanks

@dudumarc69
Copy link

dudumarc69 commented Feb 16, 2024

Creo que es un problema con el "package name" yo probe a cambiar el nombre del mismo y compilo sin problemas en SDK48 y SDK49

app.json original

"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#ffffff"
},
"package": "com.azdigital.masterkinder"
},

por

"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#ffffff"
},
"package": "com.masterkinder"
},

@oussamachah2020
Copy link

Screenshot from 2024-03-23 03-38-02

m having this issue when trying to run the prebuild

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI Versioned Expo CLI -- `npx expo start` incomplete issue: missing or invalid repro A minimal reproducible example is required for most issues
Projects
None yet
Development

No branches or pull requests