Execution failed for task ':app:installRelease' react-native - android

I wanted to create an android apk file in react-native. I followed the instructions as per the link below
https://reactnative.dev/docs/signed-apk-android
Generated upload key
Added gradle variables
Added signing config
this worked well but for below command I am getting an error
npx react-native run-android --variant=release
Error:
Task :app:installRelease FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:installRelease'.
com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package io.nativebase.market.geekyants.straptaxiapp signatures do not match previously installed version; ignoring!
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 20s
65 actionable tasks: 2 executed, 63 up-to-date
error 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
error Command failed: ./gradlew app:installRelease. Run CLI with --verbose flag
for more details.strong text
Please help..!

I had the same problem before. Check that you don't have any other version of the app installed in your phone. If this is the case, uninstall the previous version and it will work fine.
If that does not work, try updating the version number in the app/build.gradle in the android folder.
I hope it helps.

If you are running react-native run-android --variant=release to build an apk
we usually get such error but that's fine as the error is only because we aren't running an emulator or a real device.
Hence it says that the error is because it is unable to install it as there are no active devices.
I found this error today and everything is fine.

I know this question already has an accepted answer, but I ran into this as well. I had to make sure to terminate any running instances of the app on the simulator, device, and terminate Metro. Then this error went away.

Just to add:
In my case with respect to #mediaguru's answer - It worked fine on my end just mere uninstalling the installed app in the device (metro was not terminated - because I was in haste to apply the answer, and did not care to read further down to #mediaguru's addition not until mine was solved).

My gradle.properties had unsupported parameter, i.e., -XX:MaxPermSize=512m. Changing this line of code, from:
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
to
org.gradle.jvmargs=-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
fixed the problem.

Related

flutter run returns error failed to create jar file

I'm trying to run 'flutter run' but it returns the following error. Any idea on whats causing this to happen?
Using hardware rendering with device sdk gphone x86. If you notice graphics artifacts, consider enabling
software rendering with "--enable-software-rendering".
Launching lib\main.dart on sdk gphone x86 in debug mode...
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'android'.
Failed to create Jar file C:\Users\User.gradle\caches\jars-8\54252edd90659a19228cc919a3e977c6\kotlin-compiler-embeddable-1.3.50.jar.
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 5s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 6.3s
Exception: Gradle task assembleDebug failed with exit code 1
In my case, I freshly installed Flutter to my machine. I have created a new project, tried the compile it. In this first compilation process, it was taking long, so I have killed the compilation process with CTRL+C so that I can pass --verbose flag to flutter run to see what's taking so long. Then I got this error on the next verbose compilation.
Looking at the logs, I've managed to figure out that "Maybe, I have terminated the first compilation process while it was installing Gradle to my local machine, so it kinda screwed it up while it was doing its job.".
I have removed my ~/.gradle directory and rerun again and it worked flawlessly.
The problem here is, this folder
C:\Users\User.gradle\caches\jars-8\54252edd90659a19228cc919a3e977c6
Is currently empty. It should have kotlin-compiler-embeddable-1.3.50.jar. How I fixed this problem, I have searched on Google for kotlin-compiler-embeddable-1.3.50.jar. From Google, I have downloaded this kotlin-compiler-embeddable-1.3.50.jar. After downloading I have pasted that particular jar file here -> C:\Users\User.gradle\caches\jars-8\54252edd90659a19228cc919a3e977c6.
Now I am not getting this error anymore.
You can download kotlin-compiler-embeddable-1.3.50.jar from here :
https://jar-download.com/artifacts/org.jetbrains.kotlin/kotlin-compiler-client-embeddable/1.3.50/source-code

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

Task 'installDebug' not found in project ':app'.in only one react-native project

I am new to React and first tried to do a Hello World Project. I got the mentioned error but also the error, that my sdk path is not set. So I configured a ANDROID_SDK_ROOT variable. Then it worked properly.
Now I want to run the rocket chat app from github on my android device. This is the project: https://github.com/RocketChat.
After navigating into the project (root), I first started the server with npm start, showing me a successful message. Then I wanted to run it on my phone, using npx react-native run-android.
This is the output I get:
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 1m 5s
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 know there are already some posts about this error and I tried their solutions so far, but without success yet.
My device is registered and is showing when I do adb devices. The global android sdk variable is also set.
What could have gone wrong? Can someone tell me what I am missing?
Thanks for every help!
I fixed it. None of the solutions worked but I found another way.
First, dont forget to start the server. Navigate to the root folder of your project and run npm start. This should run successfully. If it says your ports are already used, just open your task manager and terminate all tasks from NodeJS.
In your android folder, run the command gradlew tasks. This will show you a list of available commands. I dont know why, but the command installDebug was not there, hence the error.
But there were other tasks which sounded similar, for example installFossDebug.
So I ran npx react-native run-android --variant=installFossDebug. But it didnt work. The console showed me a new error, saying Task installInstallFossDebug could not be found (No Typo).
I dont know why install was twice in the task, so I just ran npx react-native run-android --variant=FossDebug and voila, it worked. The app started successfully on my android device.
Good luck! :-)

Failed to launch emulator. Reason: Emulator exited before boot en React Native when react-native run-android

I am installing React Native according to this website https://medium.com/#leonardobrunolima/react-native-tips-setting-up-your-development-environment-for-windows-d326635604ea, it's very useful until I run the command react-native run-android, this is the error I receive:
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 8 workers...
info Starting JS server...
info Launching emulator...
error Failed to launch emulator. Reason: Emulator exited before boot..
> Task :app:transformNativeLibsWithMergeJniLibsForDebug FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.5/userguide/command_line_interface.html#sec:command_line_warnings
24 actionable tasks: 4 executed, 20 up-to-date
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformNativeLibsWithMergeJniLibsForDebug'.
> Could not read path 'C:\JesusApp\android\app\build\intermediates\transforms\mergeJniLibs\debug\0\lib\x86_64'.
* 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 7s
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.
* What went wrong:
Execution failed for task ':app:transformNativeLibsWithMergeJniLibsForDebug'.
> Could not read path 'C:\JesusApp\android\app\build\intermediates\transforms\mergeJniLibs\debug\0\lib\x86_64'.
* 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 7s
at checkExecSyncError (child_process.js:629:11)
at execFileSync (child_process.js:647:13)
at runOnAllDevices (C:\JesusApp\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)
at process._tickCallback (internal/process/next_tick.js:68:7)
My node version is 10, and I am working on Windows, please help, thank you.
I succeeded by doing the following steps:
Open android studio > AVD Manager > Actions (click the bottom icon) > Select Cool Boot Now.
Check your config and environment setup with instructions here, be very careful with pathes set up. Check the $PATH from your IDE's terminal.
check in the AVD that a particular Android OS is selected and installed for a virtual device you use (in my case it was not, I had yellow warning exclaim sign in an "Actions" column in an AVD's devices list).
Have your Gradle updated to at least 6.6 in the
android/gradle/wrapper/gradle-wrapper.properties
On Ubuntu after run I had to "push" switch-on button on the virtual device.
Finally, I got it up and running both on Windows 10 and Ubuntu 20.04 LTS with Android 30.
This might be the insufficient space in your machine or AVD or the mismatch in the configurations.
So, do the following steps to resolve this issue.
Verify that the environment variables are set for SDK path and adb.
Clean the project by Build -> Clean Project
Clean AVD by Open android studio > AVD Manager > Actions (click the bottom icon) > Select Cool Boot Now.
First start the android emulator on Android Studio, then execute the react-native run-android. If it doesn´t work go to android studio and do "Build -> Clean Project"
For me running
adb kill-server
and
adb start-server
worked
I also runned killall 9 node before that but it was not enough. MacOS asks for saving last state before restart also Android emulator asks before quiting it. Maybe the problem happens because saving a bad state and trying to start from that bad state. Not sure but I suspect one of these.
In my case, I've to wipe data on the virtual device.
Android Studio -> AVD -> Actions (↓) -> Wipe Data
I faced similar problem when executing my react-native code on Android Physical device. I am not sure if my solution will help.
We all know that ADB requires authorization from an Android device in order to communicate with it. It’s only by allowing the USB debugging and validating the computer’s RSA key fingerprint that we let the ADB daemon connect to our phone and control it. This is a security feature.
My phone was connected with USB and on changing USB Configuration on device, my phone gave me another prompt "Allow USB debugging?" Image available for reference. I got solution on reallow USB debugging
I had the same problem, only check the developer options and enable the debug by usb, on the device
For me, the problem ended up being quite simple. Working in react-native, I was running the following command from the terminal 'npx react-native run-android' in VS CODE. Though the emulator would run fine when started from Android Studios, I received the above error when running from the terminal in VS Code.
Solution: Run VS Code as Administrator. (or your terminal in general)
worked for me - there is not enough space on disk, Check that there is enough space on disk(where is the emulator was installed).
In my case, cool boot and wipe data didn't work. I just uninstall the virtual device and reinstall it and then it works for me.
Worked for me - reload system or clean system/android cache ./android/avd
Deleting the file app\build\intermediates\signing_config\debug\out\signing-config.json worked for me.

Categories

Resources