Error react native when run react-native run-android - java

When i want run react-native run-android command i see
FAILURE: Build failed with an exception.
What went wrong: A problem occurred configuring root project 'reactNativeCliTest'.
Could not resolve all dependencies for configuration ':classpath'.
Could not download gradle-core.jar (com.android.tools.build:gradle-core:2.2.3)
Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle-core/2.2.3/gradle-core-2.2.3.jar'.
Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle-core/2.2.3/gradle-core-2.2.3.jar'.
Connect to jcenter.bintray.com:443 [jcenter.bintray.com/75.126.118.188] failed: Connection timed out:
connect
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: 26.854 secs 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
I use genymotion .
thank you ...

RN is trying to download a new version of gradle and get error code 443. This error is related to misconfigured system files in your windows operating system. It's not related to react native and you can search about fix this error in your system.
as an experience, you have to use hotspot shield or strong vpn to download from jcenter in iran!
this link may help you: http://www.wiki-errors.com/err.php?wiki=443

Related

How to solve the problem of installing the apk through adb and getting all the permissions [duplicate]

Running npx react-native run-android is working on the android emulator, and also on a Samsung device I have. But when connecting a MI MAX 2 device, I get the following:
> Task :app:installDebug
Installing APK 'app-debug.apk' on 'MI MAX 2 - 7.1.1' for app:debug
> Task :app:installDebug 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.5/userguide/command_line_interface.html#sec:command_line_warnings
847 actionable tasks: 2 executed, 845 up-to-date
Unable to install /Users/[....]/android/app/build/outputs/apk/debug/app-debug.apk
com.android.ddmlib.InstallException: Unknown failure: Error: java.lang.SecurityException: You need the android.permission.INSTALL_GRANT_RUNTIME_PERMISSIONS permission to use the PackageManager.INSTALL_GRANT_RUNTIME_PERMISSIONS flag
at com.android.ddmlib.internal.DeviceImpl.installRemotePackage(DeviceImpl.java:1224)
at com.android.ddmlib.internal.DeviceImpl.installPackage(DeviceImpl.java:1050)
at com.android.ddmlib.internal.DeviceImpl.installPackage(DeviceImpl.java:1026)
at com.android.ddmlib.internal.DeviceImpl.installPackage(DeviceImpl.java:1015)
at ... etc, etc, etc
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:installDebug'.
> java.util.concurrent.ExecutionException: com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: Unknown failure: Error: java.lang.SecurityException: You need the android.permission.INSTALL_GRANT_RUNTIME_PERMISSIONS permission to use the PackageManager.INSTALL_GRANT_RUNTIME_PERMISSIONS flag
* 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 30s
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=4105
Unable to install /Users/[....]/android/app/build/outputs/apk/debug/app-debug.apk
Note: I tried adding the following to my AndroidManifest.xml but it didn't appear to make a difference:
<uses-permission android:name="android.permission.INSTALL_GRANT_RUNTIME_PERMISSIONS"/>
Any ideas?
Ensure that all three
Developer Options -> USB debugging
Developer Options -> USB debugging (Security settings)
Developer Options -> Install via USB
are turned on
I could fix it on a MI POCO F2 Pro enabling Developer Options -> USB debugging (Security settings) option.
On my Xiaomi Redmi Note 7, I had to turn on another option which is called "USB Debugging (Security Settings)".
It's located not far below the "USB Debugging" option.
Enable the USB debugging (Security settings) from developer option. It will ask you to insert SIM card if the phone doesn't have a SIM inserted.
The problem came for me after I removed the SIM card from my MI device.
I can't accept the USB debugging (Security settings) anymore since that..
Solution: I have tried this , I had my Sim inserted and Developer Options -> USB debugging (Security settings) and USB Debugging- Both Turned ON but in my device i was still facing the same issue then i activated : Install Via USB - Turned ON. Now Its working fine i guess my REDMI device had this additional option other phone might not have.
This webpage has all related capabilities for running Appium :
http://appium.io/docs/en/writing-running-appium/caps/index.html
In my capabilities section i also added 2 new capabilities for Actual device and imported a library saying:
import io.appium.java_client.android.appmanagement.*;
DesiredCapabilities cap= new DesiredCapabilities();
cap.setCapability("autoGrantPermissions", "true");
cap.setCapability("enforceAppInstall", "true");

Error while debugging first app in flutter using a real device

I'm using VS code without Android studio in Ubuntu 20.04. While running the first app in flutter in debugging mode in an real device produced this error given below. I also tried to change my JDK version but it didn't worked.
Launching lib/main.dart on Nokia 6 1 Plus in debug mode...
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 12s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 18.3s
Exception: Gradle task assembleDebug failed with exit code 1
Please suggest a solution!
Your gradle sync has failed for some reason.
Do this
File > Open
Navigate to your project
You will see an android folder there open that as project in a new window
Check the gradle sync issues and resolve those

Executing external libraries for cmake(Android Studio)

I am trying to build a project but its gradle is not working properly. First it was giving me error that NDK should be there so i download ndk from sdk manager but still it is giving me error and i m not able to find how can i resolve it?
Please look at my error and tell me what should i do for gradle build?
executing external native build for cmake C:\Users\Geet\Downloads\woocommercesourcecode\codecanyon-25092266-woobox-native-android-app-for-woocommerce\MainFile_Android_SourceCode\Android App source code\woobox_droid\app\CMakeLists.txt
FAILURE: Build failed with an exception.
What went wrong:
executing external native build for cmake C:\Users\Geet\Downloads\woocommercesourcecode\codecanyon-25092266-woobox-native-android-app-for-woocommerce\MainFile_Android_SourceCode\Android App source code\woobox_droid\app\CMakeLists.txt
Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Exception is:
com.intellij.openapi.externalSystem.model.ExternalSystemException: executing external native build for cmake C:\Users\Geet\Downloads\woocommercesourcecode\codecanyon-25092266-woobox-native-android-app-for-woocommerce\MainFile_Android_SourceCode\Android App source code\woobox_droid\app\CMakeLists.txt

React Native Splash Screen Issue - after modifying xml files in android folder

I would like to create a splash screen in my React Native app (not Expo) using Android Studio's emulator.
I was trying to add a splash_screen.xml file into android/app/src/main/res/drawable folder. When I put a new .xml file into the android folder the React compiler shows the following error message:
iMac:newtest Dora$ react-native run-android
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
Configure project :app
WARNING: The specified Android SDK Build Tools version (28.0.2) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.2.1.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '28.0.2'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
Task :app:mergeDebugResources FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:mergeDebugResources'.
com.android.build.gradle.tasks.ResourceException (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
BUILD FAILED in 2s
9 actionable tasks: 1 executed, 8 up-to-date
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
Command failed: ./gradlew installDebug
Error: Command failed: ./gradlew installDebug
at checkExecSyncError (child_process.js:637:11)
at Object.execFileSync (child_process.js:655:13)
at runOnAllDevices (/Users/Dora/Documents/code/react native/newtest/node_modules/react-native/local-cli/runAndroid/runAndroid.js:299:19)
at buildAndRun (/Users/Dora/Documents/code/react native/newtest/node_modules/react-native/local-cli/runAndroid/runAndroid.js:135:12)
at isPackagerRunning.then.result (/Users/Dora/Documents/code/react native/newtest/node_modules/react-native/local-cli/runAndroid/runAndroid.js:65:12)
at processTicksAndRejections (internal/process/next_tick.js:81:5)
Thank you for taking your time to help me to solve this issue!
Cheers,
Alex
Well, finally I have managed to solve this issue. It is for those who will encounter this problem during Android development.
So, what i did exactly:
1. cd into android folder and run this: ./gradlew installDebug
After this command finished without any errors
go back to the root directory and start the app using: react-native run-android
Conclusion, if you add or change any xml files in android folder, you have to do the above procedure.
That's all!
Alex

Jenkins Android Build Error: FAILURE: Build failed with an exception

I have been trying to do CI using Jenkins for my Android application. I am new to this. After following some of the tutorials, I am able to atleast set up and run the build now option. It download every pom required but while building it give below error.
============================================
C:\Windows\System32\config\systemprofile.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.1.1.aar\e796469c387c11565d873216f24c3b6f\res\drawable\abc_ic_go_search_api_material.xml: error: file not found.
C:\Windows\System32\config\systemprofile.gradle\caches\transforms-1\files-1.1\play-services-base-15.0.1.aar\7207fbd3bdb6cb696445cfc77c16e5ed\res\drawable-hdpi-v4\googleg_standard_color_18.png: error: file not found.
C:\Windows\System32\config\systemprofile.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.1.1.aar\e796469c387c11565d873216f24c3b6f\res\layout\select_dialog_singlechoice_material.xml: error: file not found.
Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details
:app:mergeDebugResources FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:mergeDebugResources'.
Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details
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.
======================================================
Can you please let me know how to resolve it?
Do let me know if anything else is required.
Maybe the path is too long. Try this:
Jenkins --> Project --> Project Configuration --> Build
Select advanced option
Check the option box "Force GRADLE_USER_HOME to use workspace"
Build your project
I solved my problem by this way, good luck!
Try updating your android gradle plugin version to 3.2.0-alpha12 or newer. AAPT2's version included in these versions contains many fixes for path support on Windows which resulted in similar errors.
you can solve this by separating into smaller group of task
make separate invoke gradle script under build tab
clean build assembleDebug
test
connectedAndroidTest
i had similar issues, when i ran assembleDebug and test together in Jenkins as a single task
When using Jenkins with Window to build Android, I face this problem myself.
I fix by add GRADLE_USER_HOME to Environment Variable:
GRADLE_USER_HOME = C:\Users\*MyUserName*\.gradle
hope this help,

Categories