React Native android adbExe does not exist - android

While i run react native android app in visual code i get this error. I need help to resolve this issue. Thanks.
FAILURE: Build failed with an exception.
What went wrong:
A problem was found with the configuration of task ':app:installDebug'.
File 'C:\Users\Supun\AppData\Local\Android\Sdk\platform-tools\adb.exe' specified for property 'adbExe' does not exist.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Get more help at https://help.gradle.org
BUILD FAILED in 4m 34s
26 actionable tasks: 26 executed
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
events.js:183
throw er; // Unhandled 'error' event
^
Error: spawn cmd.exe ENOENT
at _errnoException (util.js:1024:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
at onErrorNT (internal/child_process.js:372:16)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)

I know this is an old topic, but I'll post it here in case if anyone is having the same issue.
For me, this usually happens when WSL is being used, while Android SDK is installed under Windows (there you have adb.exe instead of adb).
Making another copy of adb.exe binary as adb resolved the issue for me:
copy adb.exe adb

Related

app:compileDebugJavaWithJavac'. > Could not find tools.jar Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`

when I use this command in the terminal:
PS C:\web dev\practice-projects\react-native\myproject> react-native run-android --no-jetifier
I get this whole error:
info JS server already running.
'adb' 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...
Starting a Gradle Daemon, 1 stopped Daemon could not be reused, use --status for details
> Task :app:compileDebugJavaWithJavac FAILED
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_warning
14 actionable tasks: 2 executed, 12 up-to-date
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Could not find tools.jar. Please check that C:\Program Files\Java\jre1.8.0_271 contains a valid JDK installation.
* 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 39s
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
My emulator isn't being launched and I have tried multiple fixes. I am getting started in react-native and don't understand the warnings or answers on similar questions. Please help.
There are few ways you can run your app,
Always works - Open the app from android studio. Select Open existing project and select android folder in your app to open the project and run from there after indexing is done.
Not sure would work and not recommended (might need release build) but you can drag your apk file that is auto generated to your simulator to install.
Add this line to gradle.properties file i.e. android/gradle.properties.
org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home. replace the jdk version name or directory if required.
Note for mac - this is not library folder within your user directory so search them in your main drive location - should be something like machintosh hd
For windows - just replace the path after org.gradle.java.home=. Should be something like C:\\Program Files\\Java\\jdk1.8.0_144
In my case it was because the JAVA_HOME path could not find it.
Close all terminals and open a new one
Find a directory like this on your Mac:
/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home
What may change is the version, but once you have it, it runs in that
path:
export JAVA_HOME = / Library / Java / JavaVirtualMachines /
jdk1.8.0_91.jdk / Contents / Home
IN MY CASE I RUN THIS COMMAND AT THE ROOT OF THE REACT NATIVE PROJECT:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
AND IT WORKED.

React Native: fail while installing the "app". Error at executing gradlew.bat

​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

React Native WebStorm Emulator cannot start - error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`

I'm new to WebStorm and React Native and I encountered an error while setting up my environment that appears unique compared to the other post I've seen.
Objective
I've set up a default project in WebStorm, my goal is to run that project on an Android emulator, I'm using a Windows PC.
What I've tried
I've set up a simple Debug configuration in WebStorm
I've also downloaded an Android Emulator thru Android Studio and I have it running on my computer.
Now when I click on run for my debug emulator I get the following error:
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 864 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
'adb' is not recognized as an internal or external command,
operable program or batch file.
info Launching emulator...
infoerror Installing the app...
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.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> 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 'C:\Users\Nicol\WebstormProjects\Dog\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 13s
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> 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 'C:\Users\Nicol\WebstormProjects\Dog\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 13s
at checkExecSyncError (child_process.js:621:11)
at execFileSync (child_process.js:639:15)
at runOnAllDevices (C:\Users\Nicol\WebstormProjects\Dog\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
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.
Other Information
Here is a picture of my Path System variables:
adb is not on your %PATH%; make sure to add the folder where adb.exe is located (usually $ANDROID_HOME/platform-tools, where $ANDROID_HOME is your Android SDK install dir, usually C:\Users\Your.Name\AppData\Local\Android\sdk, you can run where adb command in Windows cmd console to find it) to %PATH% under System environment variables and then restart WebStorm.
You also need defining %ANDROID_SDK_ROOT% environment variable per suggestion in the error message
Just to add, windows environment variables are case sensitive and adding %LOCALAPPDATA%\Android\Sdk like the react-native website says will not work, you need to add %localappdata%\Android\Sdk

Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'

I recently started to use react native, but according to Iranians Sanctions, gradle cannot build my first projects, so I used VPN and also shecan service but I get the following error:
I read React native instructions and followed them, set up an emulator, react native cli, and chocolaty service. In environments, it was written that I should define my platform-tools folder of my SDK in a variable named PATH. But in variables, I have already had path in username and in system variables. In edit, I have added my platform-tools to them. But unfortunately it didn't work yet.
The PowerShell error messages in the image are:
PS C:\Others\RN_projects\React_native_shop\shop_project> react-native run-android
Starting JS server...
Building and installing the app on the device (cd android &&
gradlew.bat installDebug)... FAILURE: Build failed with an exception.
What went wrong: A problem occurred configuring root project 'shop_project'. Could not resolve all artifacts for configuration
':classpath'. Could not resolve com.android.tools.build:gradle:3.2.1.
Required by:
project : Could not resolve com.android.tools.build:gradle:3.2.1.
Could not get resource
'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
Could not GET
'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
Connect to 127.0.0.1:8580 [/127.0.0.1] failed: Connection refused:
connect
Could not resolve com.android.tools.build:gradle:3.2.1.
Could not get resource
'https://jcenter.bintray.com/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
Could not GET
'https://jcenter.bintray.com/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
Connect to 127.0.0.1:8580 [/127.0.0.1] failed: Connection refused:
connect
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 Could not install the app on the device, read the
error above for details. Make sure you have an Android emulator
running or a device connected and have set up your Android development
environment:
https://facebook.github.io/react-native/docs/getting-started.html
events.js:173
throw er; // Unhandled 'error' event ^ Error: spawn cmd.exe ENOENT
at Process.ChildProcess._handle.onexit
(internal/child_process.js:246:19) at onErrorNT
(internal/child_process.js:421:16) at processTicksAndRejections
(internal/process/next_tick.js:76:17)
Emitted 'error' event at: at Process.ChildProcess._handle.onexit
(internal/child_process.js:252:12) at onErrorNT
(internal/child_process.js:421:16) at processTicksAndRejections
(internal/process/next_tick.js:76:17)
Add this proxy information to your gradle.properties file:
systemProp.https.proxyPort=9595
systemProp.http.proxyHost=127.0.0.1
systemProp.https.proxyHost=127.0.0.1
systemProp.http.proxyPort=9595
and set above proxy port (ex. 9595) in your vpn like psiphon.
Then sync project.
see this post
I ran into the same issue.
What I tried:
changed the gradle version, changed the gradle plugin version
changed repositories where packages are searched
set proxy settings in gradle.properties file
set proxy settings in Windows 10 network settings
None of this helped me, and I installed a proxy program that can wrap the traffic of individual applications on the computer, and it worked!
It was a Proxyfire program - it has a 30-day free version.
The problem of accessing Google services in my case is related to local restrictions.

Cannot get ionic to build android apk

I have problems getting ionic to build a proper android apk.
The ionic code is alright because I can build a proper apk on another PC.
When I run ionic build android, the android apk was successfully generated but when I install the apk, installation is not successful.
When I run ionic build android the second time, the following error was encountered;
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 guide
chapter on the daemon at
http://gradle.org/docs/2.2.1/userguide/gradle_daemon.html Please read
the following process output to find out more:
----------------------- Error occurred during initialization of VM Could not reserve enough space for object heap 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.
C:\Users\own\Dropbox\Workplace\xampp568\htdocs\ionicApp\platforms\android\cordova\node_modules\q\q.js:126
throw e;
^ Error code 1 for command: cmd with args: /s /c "C:\Users\own\Dropbox\Workplace\xampp568\htdocs\ionicApp\platforms\android\gradlew
cdvBuildDebug -b C:\Users\own\Dropbox\Wor
kplace\xampp568\htdocs\stkview\stkApp\platforms\android\build.gradle
-Dorg.gradle.daemon=true"
I was also getting the same error, then I deleted .glade file and reopened the android studio. It's working now.
I encountered similar error before. What I did was delete platforms\android\.gradle and run ionic build android again.

Categories

Resources