No able to build apk for test - android

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.

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.

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.

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

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.

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

building release apk for android in react native fails for svg files

I am getting the below error while trying to build a react native android release build. All my images are in svg format.
:app:generateReleaseResources UP-TO-DATE
:app:mergeReleaseResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeReleaseResources'.
> /Users/shamnad.shaji/Workspace/React-Native/project/android/app/src/main/res/drawable-mdpi/images_defaultprofile.svg: Error: The file name must end with .xml or .png
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 1.514 secs
I google this error and people have suggested to include the android.disableResourceValidation=true option in my gradle.properties file.
My gradle.properties looks like this.
MYAPP_RELEASE_STORE_FILE=my-release-key.keystore
MYAPP_RELEASE_KEY_ALIAS=my-key-alias
MYAPP_RELEASE_STORE_PASSWORD=password
MYAPP_RELEASE_KEY_PASSWORD=password
android.disableResourceValidation=true
And my steps to run release build are.
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bu‌​ndle --assets-dest android/app/src/main/res/
cd android/
./gradlew assembleRelease
Could someone suggest me what to do?.
I think svg support is not introduced yet https://github.com/react-native-community/react-native-svg/issues/109
you can convert your images to .png. It doesn't required any libraries to render those.
But if you want .svg. you can use below library to render your svg images
https://github.com/vault-development/react-native-svg-uri
don't use this svg library as well convert it to .png. This library also failed while release in android I just saw
i recommend using react-native-svg for including svg files in react native!

Categories

Resources