Could not be generated release apk for the react-native project - android

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.

Related

Task :app:bundleDevReleaseJsAndAssets FAILED

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.

React native bundleRelease task fails with error "The resource `index.js` was not found on a monorepo after upgrade from react-native 0.66.0 to 0.68.2

I have a mobile app and a web app for the same application and I use yarn workspaces monorepo to manage the two and the shared code in various packages. I have running this setup for a few months now successfully. I needed to make changes to same config files to get it work but it has been working very well till now.
Today, I updated from react-native 0.66.0 to 0.68.2. I made all the required changes and I am able to run the app in debug mode on iOS and Android. I am also able to build the iOS app successfully. But on Android, I am running into the following error:
warning: the transform cache was reset.
error The resource `/Users/username/Projects/myapp-monorepo/index.js` was not found.
Error: The resource `/Users/username/Projects/myapp-monorepo/index.js` was not found.
at /Users/username/Projects/myapp-monorepo/node_modules/metro/src/IncrementalBundler.js:297:24
at gotStat (node:fs:2654:21)
at FSReqCallback.oncomplete (node:fs:198:21)
info Run CLI with --verbose flag for more details.
> Task :app:bundleReleaseJsAndAssets FAILED
> Task :app:bundleReleaseJsAndAssets_SentryUpload_com.myappapp#7.0.0+7340962_7340962 FAILED
INFO 2022-05-30 19:23:40.400504 +05:30 Loaded config from /Users/username/.sentryclirc
DEBUG 2022-05-30 19:23:40.401302 +05:30 sentry-cli version: 1.74.4, platform: "darwin", architecture: "x86_64"
INFO 2022-05-30 19:23:40.401310 +05:30 sentry-cli was invoked with the following command line: "/Users/username/Projects/myapp-monorepo/node_modules/#sentry/cli/sentry-cli" "--log-level" "debug" "react-native" "gradle" "--bundle" "/Users/username/Projects/myapp-monorepo/packages/GalarmApp/android/app/build/generated/assets/react/release/index.android.bundle" "--sourcemap" "/Users/username/Projects/myapp-monorepo/packages/GalarmApp/android/app/build/generated/sourcemaps/react/release/index.android.bundle.map" "--release" "com.myappapp#7.0.0+7340962" "--dist" "7340962"
error: An organization slug is required (provide with --org)
DEBUG 2022-05-30 19:23:40.401360 +05:30 skipping update nagger because session is not attended
FAILURE: Build completed with 2 failures.
1: Task 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.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssets_SentryUpload_com.myappapp#7.0.0+7340962_7340962'.
> Process 'command '/Users/username/Projects/myapp-monorepo/node_modules/#sentry/cli/bin/sentry-cli'' 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.
As you can see, it is trying to access /Users/username/Projects/myapp-monorepo/index.js and not finding it which of course the file is not there. The file is located in the app monorepo at location /Users/username/Projects/myapp-monorepo/packages/myapp/index.js.
I am not sure where is this coming from so I can fix the corresponding config file. It seems to be related to metro, Sentry and the release build task.
I am totally stuck due to this problem. If you have any pointers, please share.
if anyone is still looking for this answer
the error is
index.js file not found
this happens when we change the index.js file name to index.jsx or index.tsx
to resolve just change the name back to index.js

Cannot package APK after adding expo to react-native project

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.

getting error while creating release apk from react native with gradlew assembleRelease

i want to release the apk but im getting error -file already exists, mkdir 'D:\mobile'.its generating file nameed mobile in the d drive. after deleting the file , executing gradlew assembleRelease again creating this file and throwing error.
Task :app:bundleReleaseJsAndAssets
warning: the transform cache was reset.
Loading dependency graph, done.
info Writing bundle output to:, D:\mobile
info Writing sourcemap output to:, D:\mobile
info Done writing bundle output
info Done writing sourcemap output
info Copying 24 asset files
error EEXIST: file already exists, mkdir 'D:\mobile'. Run CLI with --verbose flag for more details.
Error: EEXIST: file already exists, mkdir 'D:\mobile'
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
In your scenario I think you haven't made a js bundle so please make a bundle first by using 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
After that move in to your project's android directory using cd android
Before make release build make sure to clean your gradle using ./gradlew clean
And finally run this command ./gradlew assembleRelease -x bundleReleaseJsAndAssets

No able to build apk for test

BUG! exception in phase 'semantic analysis' in source unit
'BuildScript' Unsupported class file major version 57
I am trying to build the apk using following command
react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/
cd android
./gradlew assembleDebug
but I am always getting
FAILURE: Build failed with an exception.
What went wrong: Could not open settings remapped class cache for 4mbnl7wyuojndhdwxo65gs7ee
(/Users/blickx/.gradle/caches/5.5/scripts-remapped/settings_1v1qun8lpm94pweyy1199ydnb/4mbnl7wyuojndhdwxo65gs7ee/settings74e694b976d6abaa826c8abac43e9de8).
Could not open settings generic class cache for settings file '/Users/blickx/Desktop/dumont-reactnative/Dumont/android/settings.gradle'
(/Users/blickx/.gradle/caches/5.5/scripts/4mbnl7wyuojndhdwxo65gs7ee/settings/settings74e694b976d6abaa826c8abac43e9de8).
BUG! exception in phase 'semantic analysis' in source unit 'BuildScript' Unsupported class file major version 57
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 1s
Please help.
Use this command
react-native run-android --variant=release
It will Create Apk in Debug-mode.

Categories

Resources