I've been developing a react native app for a while now and I was able to generate APKs using the ./gradlew assembleRelease command. I recently added expo to the project as I replaced the react-native-camera library with expo-camera. My debug builds are running fine (using react-native run-android). But when I try to package the app into an APK, I'm met with the following error:
./gradlew assembleRelease
> Configure project :app
Installing unimodules:
unimodules-core#6.0.0 from /Users/anil/testing/node_modules/#unimodules/core
unimodules-react-native-adapter#5.7.0 from /Users/anil/testing/node_modules/#unimodules/react-native-adapter
expo-application#2.4.1 from /Users/anil/testing/node_modules/expo-application
expo-camera#9.1.1 from /Users/anil/testing/node_modules/expo-camera
expo-constants#9.3.5 from /Users/anil/testing/node_modules/expo-constants
expo-error-recovery#1.4.0 from /Users/anil/testing/node_modules/expo-error-recovery
expo-file-system#9.3.0 from /Users/anil/testing/node_modules/expo-file-system
expo-font#8.4.0 from /Users/anil/testing/node_modules/expo-font
expo-image-loader#1.3.0 from /Users/anil/testing/node_modules/expo-image-loader
expo-keep-awake#8.4.0 from /Users/anil/testing/node_modules/expo-keep-awake
expo-linear-gradient#8.4.0 from /Users/anil/testing/node_modules/expo-linear-gradient
expo-location#10.0.0 from /Users/anil/testing/node_modules/expo-location
expo-permissions#10.0.0 from /Users/anil/testing/node_modules/expo-permissions
expo-secure-store#9.3.0 from /Users/anil/testing/node_modules/expo-secure-store
expo-splash-screen#0.8.1 from /Users/anil/testing/node_modules/expo-splash-screen
expo-sqlite#8.5.0 from /Users/anil/testing/node_modules/expo-sqlite
expo-updates#0.4.1 from /Users/anil/testing/node_modules/expo-updates
unimodules-app-loader#1.4.0 from /Users/anil/testing/node_modules/unimodules-app-loader
unimodules-barcode-scanner-interface#5.4.0 from /Users/anil/testing/node_modules/unimodules-barcode-scanner-interface
unimodules-camera-interface#5.4.0 from /Users/anil/testing/node_modules/unimodules-camera-interface
unimodules-constants-interface#5.4.0 from /Users/anil/testing/node_modules/unimodules-constants-interface
unimodules-face-detector-interface#5.4.0 from /Users/anil/testing/node_modules/unimodules-face-detector-interface
unimodules-file-system-interface#5.4.0 from /Users/anil/testing/node_modules/unimodules-file-system-interface
unimodules-font-interface#5.4.0 from /Users/anil/testing/node_modules/unimodules-font-interface
unimodules-image-loader-interface#5.4.0 from /Users/anil/testing/node_modules/unimodules-image-loader-interface
unimodules-permissions-interface#5.4.0 from /Users/anil/testing/node_modules/unimodules-permissions-interface
unimodules-sensors-interface#5.4.0 from /Users/anil/testing/node_modules/unimodules-sensors-interface
unimodules-task-manager-interface#5.4.0 from /Users/anil/testing/node_modules/unimodules-task-manager-interface
> Task :react-native-video:compileReleaseJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
> Task :app:bundleReleaseJsAndAssets
warning: the transform cache was reset.
Welcome to React Native!
Learn once, write anywhere
TypeError: (intermediate value).eachMapping is not a function
error index.js: (intermediate value).eachMapping is not a function. Run CLI with --verbose flag for more details.
at toBabelSegments (/Users/anil/testing/node_modules/metro/node_modules/metro-source-map/src/source-map.js:167:46)
at /Users/anil/testing/node_modules/metro/src/JSTransformer/worker.js:425:15
at Generator.next (<anonymous>)
at asyncGeneratorStep (/Users/anil/testing/node_modules/metro/src/JSTransformer/worker.js:75:24)
at _next (/Users/anil/testing/node_modules/metro/src/JSTransformer/worker.js:95:9)
at /Users/anil/testing/node_modules/metro/src/JSTransformer/worker.js:100:7
at new Promise (<anonymous>)
at /Users/anil/testing/node_modules/metro/src/JSTransformer/worker.js:92:12
at JsTransformer._minifyCode (/Users/anil/testing/node_modules/metro/src/JSTransformer/worker.js:437:7)
> Task :app:bundleReleaseJsAndAssets FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssets'.
> Process 'command 'node'' finished with non-zero exit value 1
* 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.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.5/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 1m 4s
93 actionable tasks: 93 executed
I tried the following before running release:
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
but that does not seem to fix the issue.
When I use Android Studio and use the menu option Build -> Build Bundle -> Build APK(s), I get the debug build of the app (the one that looks for the react-native server). Currently, in our distribution setup, I can only use APKs. App Bundle is not supported yet. I also tried updating the metro-react-native-babel-preset version to the latest. That did not seem to make any difference either.
Related
When i try to run
cd android
./gradlew assemleRelease
This is terminal output
Task :app:bundleDevReleaseJsAndAssets
warning: the transform cache was reset.
Welcome to Metro v0.72.3
Fast - Scalable - Integrated
info Writing bundle output to:, C:\Users\CABBAR\Documents\github repo\TarifistClient\android\app\build\generated\assets\react\dev\release\index.android.bundle
info Writing sourcemap output to:, C:\Users\CABBAR\Documents\github repo\TarifistClient\android\app\build\intermediates\sourcemaps\react\dev\release\index.android.bundle.packager.map
info Done writing bundle output
info Done writing sourcemap output
info Copying 286 asset files
info Done copying assets
'C:\Users\CABBAR\Documents\github' is not recognized as an internal or external command,
operable program or batch file.
Task :app:bundleDevReleaseJsAndAssets FAILED
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
Where:
Script 'C:\Users\CABBAR\Documents\github repo\TarifistClient\node_modules\react-native\react.gradle' line: 286
What went wrong:
Execution failed for task ':app:bundleDevReleaseJsAndAssets'.
Process 'command 'cmd'' finished with non-zero exit value 1
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.
==============================================================================
Get more help at https://help.gradle.org
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
BUĀ¦LD FAILED in 1m 29s
6 actionable tasks: 1 executed, 5 up-to-date
PS C:\Users\CABBAR\Documents\github repo\TarifistClient\android>
i have tried :
`cd android` `./gradlew --stop` `./gradlew clean` and
also deleted node_modules and loaded again with `yarn install`
after that when i run `cd android `
`./gradlew assemleRelease` it still same problem.
// also i tried this command `react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res` but terminal gibing this error:
react-native: The term 'react-native' is not recognized as a name of a cmdlet, function, script file, or
executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
I'm on Windows 10, I have installed Java 19 and Gradle 7.6 and I set the environment path variable.
I'm trying to run a cordova android app i just created, I didn't add anything from the base project, I just ran the inital commands cordova create app-vita cd app-vita cordova add platform android cordova run android and after the last command i get
> Task :app:processDebugMainManifest FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module #1a261029
* 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.
* Get more help at https://help.gradle.org
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.1.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 21s
34 actionable tasks: 34 executed
Command failed with exit code 1: D:\app-vita\platforms\android\gradlew cdvBuildDebug -b D:\app-vita\platforms\android\build.gradle
I really don't know what to do, I haven't done anything except creating the project
I'm new to using React and have been following along in a tutorial for a project to learn. Occasionally, I encounter an error that stops my progress, then I search the error, and I generally find some solution. But in this case, I am having a hell of a time. Part of the issue is that I am so new to developing software that I sometimes am unsure of how to implement someone's solution. And, in particular, this issue seems like it is not simply contained to a single project, which means that new projects I create with React are now also experiencing similar issues.
Here's the issue. When I use npm run android, I get the following output:
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1940 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
info Launching emulator...
error Failed to launch emulator. Reason: Could not start emulator within 30 seconds..
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
> Configure project :react-native-reanimated
> No AAR for react-native-reanimated found. Attempting to build from source.
> Native libs debug enabled: false
> Android gradle plugin: 4.2.2
> Gradle: 7.2
> building Reanimated2
> Task :app:generatePackageList FAILED
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.2/userguide/command_line_interface.html#sec:command_line_warnings
10 actionable tasks: 3 executed, 7 up-to-date
FAILURE: Build failed with an exception.
* Where:
Script 'C:\\Users\\Astuertz\\Dev\\Values2\\node_modules#react-native-community\\cli-platform-android\\native_modules.gradle' line: 122
* What went wrong:
Execution failed for task ':app:generatePackageList'.
> argument type mismatch
* 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.
* Get more help at https://help.gradle.org
BUILD FAILED in 8s
error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* Where:
Script 'C:\\Users\\Astuertz\\Dev\\Values2\\node_modules#react-native-community\\cli-platform-android\\native_modules.gradle' line: 122
* What went wrong:
Execution failed for task ':app:generatePackageList'.
> argument type mismatch
* 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.
* Get more help at https://help.gradle.org
BUILD FAILED in 8s
at checkExecSyncError (node:child_process:828:11)
at execFileSync (node:child_process:866:15)
at runOnAllDevices (C:\Users\Astuertz\Dev\Values2\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)
at async Command.handleAction (C:\Users\Astuertz\Dev\Values2\node_modules\react-native\node_modules\#react-native-community\cli\build\index.js:182:9)
Someone had said that Gradle version 7 is incompatible with the current version of React and that it needs to be downgrade to version 7. I tried changing the version in the wrapper file for the Android folder, as well as taking someone's suggestion to change it in the Android Studio "Project Structure." In either case, the error either persisted or merely gave me a different error. What is going on here?
I've been trying to get my apps to run and compile but am in over my head.
I'm trying to build my apk using ./gradlew bundleRelease but I always get this error:
error EISDIR: illegal operation on a directory, open 'P:\React'. Run CLI with --verbose flag for more details.
Error: EISDIR: illegal operation on a directory, open 'P:\React'
> Task :app:bundleReleaseJsAndAssets FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssets'.
> Process 'command 'npx.cmd'' finished with non-zero exit value 1
* 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.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings
I also tried ./gradlew app:assembleRelease but I get the same error. I also created my project using npx.
I tried everything, I even updated the project gradle verion but I would still get the same error. But the solution was just this:
cd android
clean your gradle:
./gradlew clean
then:
./gradlew assembleRelease -x bundleReleaseJsAndAssets
I am getting these errors
Task :app:bundleReleaseJsAndAssets
warning: the transform cache was reset.
Loading dependency graph, done.
info Writing bundle output to:, C:\KLS
info Writing sourcemap output to:, C:\KLS
error EPERM: operation not permitted, open 'C:\KLS'. Run CLI with --verbose flag for more details.
Error: EPERM: operation not permitted, open 'C:\KLS'
Task :app:bundleReleaseJsAndAssets FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssets'.
Process 'command 'npx.cmd'' finished with non-zero exit value 1
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.
Get more help at https://help.gradle.org
BUILD FAILED in 4m 9s
42 actionable tasks: 2 executed, 40 up-to-date
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/
Run this command into the terminal into your project Dir. It will create the assets and adding the drawable files into the assets dir and then
clean Project & Rebuild
Now try to make the release build from android studio.
May be you will get the duplicate resource error. In that case,
remove the drawables folder && raw folder in res dir
Hope it will work.