I build an app on Ionic framework, it works on the browser but when I try to compile it on the emulator I have got this error:
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=C:\Users\user\AppData\Local\Android\Sdk (DEPRECATED)
Starting a Gradle Daemon (subsequent builds will be faster)
FAILURE: Build failed with an exception.
What went wrong:
Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the User Manual chapter on the daemon at https://docs.gradle.org/5.3.1/userguide/gradle_daemon.html
Process command line: C:\Program Files (x86)\Java\jdk1.8.0_201\bin\java.exe -Xmx2048m -Dfile.encoding=windows-1252 -Duser.country=SA -Duser.language=ar -Duser.variant -cp C:\Gradle\gradle-5.3.1\lib\gradle-launcher-5.3.1.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 5.3.1
Please read the following process output to find out more:
Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap
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
C:\Gradle\gradle-5.3.1\bin\gradle: Command failed with exit code 1
[ERROR] An error occurred while running subprocess cordova.
cordova run android exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
This is because the path to Android Sdk is not set correctly. Please check the correct path for Sdk, tools, platform-tools, emulator and Android build-tools.
Please, realize that the configuration recommended for Ionic has changed a
bit. Now the notation recommended is as follows:
ANDROID_SDK_ROOT=/home/username/Android/Sdk (recommended setting)
ANDROID_HOME=/home/username/Android/Sdk (DEPRECATED)
In Linux or Mac OS X configure the path into the ~/.bashrc, ~/.bash_profile file:
export ANDROID_SDK_ROOT=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_SDK_ROOT/tools/bin
export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools
export PATH=$PATH:$ANDROID_SDK_ROOT/emulator
export PATH=$PATH:$ANDROID_SDK_ROOT/build-tools
At the end, after save the configuration dont forget to do the command:
source ~/.bashrc
or as your case
source ~/.bash_profile
For the Windows users check the global variables.
Try to Run npm cache clean and re-install cordova...worked for me.
I finally found the solution from a related solved topic: The solution is:
ionic platform rm android
ionic platform add android#latest
ionic resources
ionic run android
ionic repair worked for me. Just give it a try and see if that works for you. Good luck!
Related
I am building a React-Native project on Mac OS. My Mac is Mac Mini which is using the new Apple M1 chip. I can build and run my project on iOS simulator using "react-native run-android" command. But when I run "react-native run-android" command, it is not working.
I downloaded and installed the Java JDK. When I type in "java -version" in the terminal, I can see the following output.
openjdk version "17" 2021-09-14 LTS
OpenJDK Runtime Environment Zulu17.28+13-CA (build 17+35-LTS)
OpenJDK 64-Bit Server VM Zulu17.28+13-CA (build 17+35-LTS, mixed mode, sharing)
Then I downloaded and installed the latest version of Android Studio. It is installed and Android SDK is located in the following path.
/Users/waihein/Library/Android/sdk
I have the following content in the ~/.hash_profile file.
export PATH="/usr/local/bin:$PATH"
export ANDROID_HOME=/Users/waihein/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:/Users/waihein/Library/Android/sdk/platform-tools/
Within my react-native project folder, when I run "react-native run-android", I got the following output.
* What went wrong:
Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the User Manual chapter on the daemon at https://docs.gradle.org/6.8/userguide/gradle_daemon.html
Process command line: /Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home/bin/java -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.invoke=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country=GB -Duser.language=en -Duser.variant -cp /Users/waihein/.gradle/wrapper/dists/gradle-6.8-all/9emh0d32e025cam7aasxcw002/gradle-6.8/lib/gradle-launcher-6.8.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 6.8
Please read the following process output to find out more:
-----------------------
Unrecognized VM option 'MaxPermSize=512m'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
* 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
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
I tried using "sudo react-native run-android" too, I got the same error.
When I run "react-native doctor" command, I got the following output.
But I installed the Android studio correctly. What is wrong with my configuration or installation and how can I fix it?
Although the react native docs don’t specify a range of JDK versions that work with RN, I personally haven’t been able to get anything but OpenJDK8 to work. Try installing that and setting the JAVA_HOME environment variable to its path.
I think the package for it got renamed recently in Homebrew - you’d run ‘brew install temurin8’ now.
Well, I am trying to install all components to run React Native apps on my computer, but I have been working on this for four days and I always got the same error message:
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
I reinstalled the components three times, but only some things changed, like the time that jumped from 30 minutes to 3 hours, and the quantity of text that shows on my screen.
I tried a lot of solutions I found on the internet, like uninstall the global react-native-cli and use .\gradlew clean however it did not work because I got a message saying that "." is not recognized like a command. I really do not know how to correct it...
Bellow, my computer configurations:
System: Windows 7 professional SP1
Processor: Intel Atom CPU D525 #1.80Ghz 1.79GHz
RAM memory: 2,00GB
Type of system: 32-bit operating system
The React Native component versions I installed:
Chocolatey: v0.10.15
Node.js: v12.13.0
Npm: 6.12.0
Yarn: 1.22.5
Python: 2.7.18
JDK 8: 1.8.0_271
Android Studio: 3.6.3
Observations:
I also have Python 3.8 installed
I also tried the command line tools only before the Android Studio IDE
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:installDebug'.
> com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: Unknown failure: Exception occurred while executing:
android.os.ParcelableException: java.io.IOException: Requested internal only, but not enough space
at android.util.ExceptionUtils.wrap(ExceptionUtils.java:34)
at com.android.server.pm.PackageInstallerService.createSession(PackageInstallerService.java:413)
at com.android.server.pm.PackageManagerShellCommand.doCreateSession(PackageManagerShellCommand.java:2418)
at com.android.server.pm.PackageManagerShellCommand.runInstall(PackageManagerShellCommand.java:907)
at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:158)
at android.os.ShellCommand.exec(ShellCommand.java:103)
at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:22015)
at android.os.Binder.shellCommand(Binder.java:634)
at android.os.Binder.onTransact(Binder.java:532)
at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:2809)
at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4070)
at android.os.Binder.execTransact(Binder.java:731)
Caused by: java.io.IOException: Requested internal only, but not enough space
at com.android.internal.content.PackageHelper.resolveInstallVolume(PackageHelper.java:232)
at com.android.internal.content.PackageHelper.resolveInstallVolume(PackageHelper.java:148)
at com.android.internal.content.PackageHelper.resolveInstallVolume(PackageHelper.java:163)
at com.android.server.pm.PackageInstallerService.createSessionInternal(PackageInstallerService.java:510)
at com.android.server.pm.PackageInstallerService.createSession(PackageInstallerService.java:411)
... 10 more
* 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 1h 47m 4s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
Note: C:\Users\myusername\Desktop\appproject1\android\app\src\debug\java\com\appproject1\ReactNativeFlipper.java uses or overrides a deprecated API.
C:\Users\myusername\Desktop\appproject1>
I apologize for not being able to give you more information. I ask you to help me, please.
Edit:
I would like to give some tips about problems I got when trying to use react-native:
Low space on the smartphone. Please try to install something in the store, if you cannot do it, you need to free some space.
Some problems could be solved only by trying to run the project by Android Studio, please try it too.
Cache may be your problem. Try it inside the project folder:
cd android
gradlew clean
after it, run the project again returning to the project folder using cd ..:
cd ..
react-native run-android
Issue:
> Caused by: java.io.IOException: Requested internal only, but not enough space
solution -1-
replace
android:installLocation="internalOnly"
with
android:installLocation="preferExternal"
solution -2-
make some space on the device / emulator
I have installed all necessary SDK , Platform Tools . I've the emulator open and running, adb added in PATH. Still this error isn't letting me through.
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 967 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
info Launching emulator...
/bin/sh: adb: command not found
info Installing the app...
error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
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.2/userguide/command_line_interface.html#sec:command_line_warnings
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose
FAILURE: Build failed with an exception.flag for more details.
* What went wrong:
Could not determine the dependencies of task ':app:installDebug'.
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '/Users/manndave/IdeaProjects/MyFirstReactNative/android/local.properties'.
* 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 3s
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081```
Please run the following from terminal, inside the project folder
export ANDROID_HOME=/Users/{yourusername}/Library/Android/sdk
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
Then npm run android
In my case, I had running Metro Bundler from another project. Closing it is solved my issue.
Complete Console Output is below
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 967 file(s) to forward-jetify. Using 8 workers...
info JS server already running.
info Installing the app...
FAILURE: Build failed with an exception.
* What went wrong:
Could not initialize class org.codehaus.groovy.runtime.InvokerHelper
* 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 696ms
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
Could not initialize class org.codehaus.groovy.runtime.InvokerHelper
* 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 696ms
at makeError (/Users/user/Desktop/sa/MyReactApp/node_modules/execa/index.js:174:9)
at /Users/user/Desktop/sa/MyReactApp/node_modules/execa/index.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async runOnAllDevices (/Users/user/Desktop/sa/MyReactApp/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:5)
at async Command.handleAction (/Users/user/Desktop/sa/MyReactApp/node_modules/#react-native-community/cli/build/index.js:186:9)
Bash_profile
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
export ANDROID_SDK_ROOT=$ANDROID_HOME
export ANDROID_AVD_HOME=$HOME/.android/avd
alias emulator='$ANDROID_SDK_ROOT/tools/emulator'
Requested Attachments
Android SDK Link From Android Studio
SDK Tools Installed
npx #react-native-community/cli doctor Result
Installed Android Emulator
Nexus 6P (Android R and Pie)
New To React Native
it works perfectly on iOS
but it fails to launch in Android Simulator
Tried Ways
npm start
npx react-native run-ios
npx react-native run-android
It is Probably because of JDK version as mention above.
You can verify by running react native doctor
npx #react-native-community/cli doctor
Install JDK 1.8 and setup $JAVA_HOME env variable and try to run the app again.
The error is due to lower version of JDK or JDK not installed.
your problem can be resolved just follow these steps:
To jetify / convert node_modules dependencies to AndroidX
Imagine you have a react-native project. One of your library dependencies converts to AndroidX., and you need to use the new version.
So now you need to convert your app to AndroidX, but many of your react-native libraries ship native Java code and have not updated. How is this done?
First, use Android Studio's refactoring tool to convert your app re: the Android developer docs
npm install --save-dev jetifier
npx jetify
npx react-native run-android (your app should correctly compile and work)
Call npx jetify run in the postinstall target of your package.json (Any time your dependencies update you have to jetify again
you can follow this link as well: https://www.npmjs.com/package/jetifier
feel free for any confusion.
This link is the complete solution but here is a little problem if you have win32 but if you have win64 you are good to go.
**https://www.npmjs.com/package/jetifier#do_you_need_this**
hope this answer will be useful for you
feel free for any problem.
The error is due to the version of JDK or JDK not installed.
i think you need to solve in the section:
open the androind folder with android studio
then file-> project structure -> SDK location
and in here you can change, in my case i change the version
before that, for to know what was the error:
i realized what is the problem with this command
npx #react-native-community/cli doctor
i got these errors:
Please make changes as per below to resolve this error.
Install Java SDK version: 14 or above.
JDK Download link: https://www.oracle.com/java/technologies/javase-jdk14-downloads.html
In gradle-wrapper.properties please use grade version 6.3 or above.
For e.g:distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
After creating a react native project, I tried to run it on my android device. I enter adb devices into the terminal, I saw my device. I ran react-native run-android. And after a while Task 'installDebug' not found in project ':app' popped up.
Jetifier found 962 file(s) to forward-jetify. Using 4 workers
...info Starting JS server...
'D:\Android\android-sdk\platform-tools' is not recognized as an internal or external command, operable program or batch file.
info Launching emulator...
error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
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
FAILURE: Build failed with an exception.
* What went wrong:
Task 'installDebug' not found in project ':app'.
* Try:
Run gradlew tasks to get a list of available tasks.
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 15s
error Failed to install the app. Make sure you have the Android development environment set up:
https://reactnative.dev/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8
081
FAILURE: Build failed with an exception.
* What went wrong:
Task 'installDebug' not found in project ':app'.
Here is react-native info
info Fetching system and libraries information...
System:
OS: Windows 7 6.1.7601
CPU: (4) x64 Intel(R) Core(TM) i3-2100 CPU # 3.10GHz
Memory: 881.91 MB / 3.97 GB
Binaries:
Node: 10.16.1 - C:\Program Files\nodejs\node.EXE
Yarn: 1.17.3 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK: Not Found
IDEs:
Android Studio: Version 3.2.0.0 AI-181.5540.7.32.5014246
Languages:
Python: Not Found
npmPackages:
#react-native-community/cli: Not Found
react: 16.11.0 => 16.11.0
react-native: 0.62.0 => 0.62.0
npmGlobalPackages:
*react-native*: Not Found
I ran gradlew tasks and I did not see installDebug under the install tasks. I am sure that I set up the environment variables correctly, including android SDK, JDK. I tried reinstalling react-native. I put the location of my sdk in local.properties under android folder. I ran gradlew installDebug and installDebug not found in root project '[app's name]' appeared. None of the solutions on the internet worked.
Can anyone please help me to sort out this?
Thank you.
I also faced the same problem.
Here is what works for me.
I opened the Android Project in Android Studio.
This can be located at YourReactNativeProjectFolder/android
When I opened this project in Android Studio, it was missing the configuration. Wait for some time and allow Android Studio to configure it and ask you to update the Gradle. Update the Gradle and now you can run your project from the Android Studio or using the command line "npx react-native run-android"
I hope that it will be helpful.
Best
try the following command at the project root:
cd android && ./gradlew assembleDebug && ./gradlew installDebug
The solution is loading the /android folder in the Android Studio and let it update the Gradle. After that you will be able to run react-native run-android
I had the same error.Try the following command, it will show the exact error of the code.
cd android && ./gradlew buildRelease
for me => Mac m1
1.- npx react-native run-android raises metro terminal(stay open metro).
2.- open proyect in Android in the folder android and launch Emulator on Device.(wait....).
3.- later android launch the app and Device error.
4.- in terminal type 'adb reverse tcp:8081 tcp:8081'(in the folder android).
5.- in Device press reload
sorry my English =)
and I hope it will help them