Getting error in building the android App in Ionic 6 - android

I am trying to build the android app and getting the error related to Gradle. basically when I change the API level from 30 to 31 in
config.xml
it gives me below error otherwise it runs smoothly.
Error:
BUILD FAILED in 3s
21 actionable tasks: 3 executed, 18 up-to-date
Command failed with exit code 1: C:\Users\123\OneDrive\Documents\PixelP\stopwatch\platforms\android\gradlew :app:bundleRelease -b C:\Users\123\OneDrive\Documents\PixelP\stopwatch\platforms\android\build.gradle
[ERROR] An error occurred while running subprocess cordova.
cordova.cmd build android --release exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
Please suggest me solution of it, Thanks in advance.
I tried to remove and android as well as cleaning Gradle and much more thing but nothing can be solved.

Related

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 run-android Only works on the first build

The first time I run my react-native app the emulator works (using Android Studio Galaxy Nexus). However, when I close the emulator and try again I get the errors below:
PS C:\Users\4chea\pexhouseV2> react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1197 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..
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
> Task :app:stripDebugDebugSymbols UP-TO-DATE
Compatible side by side NDK version was not found.
> Task :app:installDebug FAILED
Skipping device 'emulator-5554' (emulator-5554): Device is OFFLINE.
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
160 actionable tasks: 2 executed, 158 up-to-date
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:installDebug'.
> com.android.builder.testing.api.DeviceException: No online devices found.
* 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 24s
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 is open while this happens and says "failed to connect to metro server"
This here tells you the problem.
info Launching emulator...
error Failed to launch emulator. Reason: Emulator exited before boot..
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
Something is wrong with your emulator. Try rebooting your system. If that doesn't work, try making a new emulator and see if that one works better. Also, I would turn off the Quickstart feature on your emulator - it may ask you as you shut it down if you want to save its memory state for faster boot times. I've had issues with that in the past similar to this.
Let me know if that changes anything. Good luck.

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

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.

Build error when using Cordova google-analytics-plugin

I am trying to add https://github.com/nickdrewe/google-analytics-plugin to my cordova project. But the build failed. Here are what I tried:
Install google playservices 21 instead of 19. Edit plugin.xml to point to 21 but still don't work.
Remove google playservices completely and use framework instead https://github.com/nickdrewe/google-analytics-plugin/commit/cb8e78f17472ae2c8b4db613273764a7260b4e34 but still build error
I also tried android update sdk --no-ui --all --filter "extra-google-m2repository" from https://groups.google.com/forum/#!topic/adt-dev/UXW0Hl0UVXk
The error I got:
FAILURE: Build failed with an exception.
* What went wrong:
Failed to notify build listener.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
/vagrant/MyProject/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: /vagrant/MyProject/platforms/android/gradlew with args: cdvBuildDebug,-b,/vagrant/MyProject/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /vagrant/MyProject/platforms/android/cordova/build: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: /vagrant/MyProject/platforms/android/cordova/build: Command failed with exit code 1
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:134:23)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
I am using Ionic 1.5.5 and Cordova Android 4.0.2
Any help?
I am open to alternative Google Analytics plugin but I found https://github.com/phonegap-build/GAPlugin causing Android app crashing upon start.
I just tried to reproduce your error - and there is none. I build a new project with the plugin you linked and also the console plugin. The build was totaly fine and successfull.
As far as i see you edited your gradle build settings for speeding up the gradle build. -Dorg.gradle.daemon=true... as far as i read through the documents this must be -org.gradle.daemon=true or is the D sth like an operator or a variable which has to be there?
What you can also try is to run the cmd as an administrator.
Cordova downgrade from 5.1.1 to 4.3.2 fixed the problem for many users.

Cordova Build Failed: Error starting modern compiler

HI i am trying to generate cordova 3.5.1.jar .but getting the below error in my command prompt window.Can any one help to sp
BUILD FAILED
E:\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\sdk\too
ls\ant\build.xml:720: The following error occurred while executing
this line:
E:\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\sdk\tools\ant\build.xml:734: Error starting modern compiler
Total time: 5 seconds
You probably have messed up with your Java installation by accident.
If you want to troubleshoot Cordova build process you could run command below:
cd <path/to/project>
ant -v -f ./platforms/android/build.xml debug
assuming that you are using cordova tool for the running build.

Categories

Resources