React Native make android app load in genymotion - react-native

I am trying to build an android app in react native. I have followed the official guidelines and downloaded genymotion and created a new project in react native. How do I open my project in genymotion?
I am getting the following error in my terminal
FAILURE: Build failed with an exception.
Where:
Build file '/Users/adamkatz/Projects/testAndroid/android/app/build.gradle' line: 69
What went wrong:
A problem occurred evaluating project ':app'.
SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
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: 6.504 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/android-setup.html
when i added the following
export ANDROID_HOME=/usr/local/opt/android-sdk
i get the following error message
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring project ':app'.
failed to find Build Tools revision 23.0.1
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: 3.735 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/android-setup.html

You must define ANDROID_HOME I copied the relevant parts from the React Native setup guide below and link below that.
On Mac, add this to your ~/.bashrc, ~/.bash_profile or whatever your shell uses:
If you installed the SDK via Homebrew, otherwise ~/Library/Android/sdk
export ANDROID_HOME=/usr/local/opt/android-sdk
On Linux, add this to your ~/.bashrc, ~/.bash_profile or whatever your shell uses:
export ANDROID_HOME=<path_where_you_unpacked_android_sdk>
On Windows, go to Control Panel -> System and Security -> System -> Change settings -> Advanced -> Environment variables -> New
https://facebook.github.io/react-native/docs/android-setup.html#define-the-android-home-environment-variable

Add a properties file called local.properties in your android project directory (e.g. open your project named as xyz and add this file) and add:
sdk.dir=C\:\\Users\\jeey\\AppData\\Local\\Android\\Sdk
in the file and save it.
Re-run your project.

It seems you have no build tool version 23.0.1 installed in your pc. Lunch your sdk manager and install the specified version.
For more detail.
Go through setting up React native to use with Genny motion here
Android Setup - React Native

Related

Build command in detox

Looking at this doc: https://github.com/wix/Detox/blob/master/docs/APIRef.Configuration.md
It says that the
Build command (either xcodebuild, react-native run-ios, etc...), will
be later available through detox CLI tool.
I'm trying to setup the build command to work with Android. Am I supposed to add react-native run-android to the build command? What do they mean by Detox CLI tool?
The build field is optional, and should contain whichever execution logic needed in order to have the .apk file set and ready in the path specified in binaryPath. You are more than welcome to refer to the Detox example project, which was set up as a reference exactly for these type of questions.
In any case, from the react-native CLI tool's help: react-native run-android = builds your app and starts it on a connected Android emulator or device. That makes it not very suitable, as we typically want to build the app, and have detox launch the emulator (optional) and install the app on the device(s), as needed.

A problem occurred configuring project ':#sentry_react-native' SDK location not found

I'm on MacOS trying to run a react native (0.59.9) app on Android emulator. I've integrated Sentry using the wizard. Works fine on iPhone. On Android, this happens:
I try to run the app w/ react-native run-android
Build fails.
A problem occurred configuring project ':#sentry_react-native'.
SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
I go into the android folder and create a local.properties file and paste this in:
sdk.dir=C:/Users/my_name/Library/Android/sdk
I try again to run the app w/ react-native run-android
Build fails.
A problem occurred configuring project ':#sentry_react-native'.
The SDK directory '/Users/my_name/project_path/android/C:/Users/my_name/Library/Android/sdk' does not exist.
Why is it concatenating the SDK dir w/ my project path? That doesn't make sense to me. How do I fix this?
this isn't a Sentry issue, but an Android environment issue, please look at https://reactnative.dev/docs/getting-started.html and set your Android env. properly.
Look for "Android development environment", good luck :)

Build failure: React Native Android

I am setting up my environment to start developing react native apps. I keep getting the following error:
PS C:\map\development\learnreact\react-native\helloworld> react-native
run-android Starting JS server... Building and installing the app on
the device (cd android && gradlew.bat installDebug)...
Configure project :app Observed package id 'platform-tools' in inconsistent location
'C:\Users\bheka\AppData\Local\Android\Sdk\platform-tools' (Expected
'C:\Users\bheka\AppData\Local\Android\Sdk\platform-tools\platform-tools')
Checking the license for package Android SDK Build-Tools 27.0.3 in
C:\Users\bheka\AppData\Local\Android\Sdk\platform-tools\licenses
Warning: License for package Android SDK Build-Tools 27.0.3 not
accepted. Checking the license for package Android SDK Platform 26 in
C:\Users\bheka\AppData\Local\Android\Sdk\platform-tools\licenses
Warning: License for package Android SDK Platform 26 not accepted.
FAILURE: Build failed with an exception.
What went wrong: A problem occurred configuring project ':app'.
Failed to install the following Android SDK packages as some licences have not been accepted.
platforms;android-26 Android SDK Platform 26
build-tools;27.0.3 Android SDK Build-Tools 27.0.3 To build this project, accept the SDK license agreements and install the missing
components using the Android Studio SDK Manager. Alternatively, to
transfer the license agreements from one workstation to another, see
http://d.android.com/r/studio-ui/export-licenses.html Using Android
SDK: C:\Users\bheka\AppData\Local\Android\Sdk\platform-tools
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 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 have accepted licenses using .\sdkmanager --licenses but no luck. I have reinstalled the sdk using the sdk manager in android studio with no luck. Anyone know what I should do?
Make sure the sdkbuildtools used by Android Studio and your emulator are the same as the ones in your build.gradle file in your project folder. If they do not match then either change the build.gradle file to use the installed sdk version. What probably happened is you have sdk 27 used by your android studio and your rn project tried to build it using sdk 26. Accepting the license will not change anything because while it's accepted it is still not used by your emulator and you Android Studio.
Hope that helps!
I had similar issue and was resolved by fixing environment variable, ANDROID_SDK_ROOT. It was previously pointing to .../sdk/platform-tools/ and later worked by changing it to .../sdk

react-native run-android fails, could not install app

I m having a problem when I try to run my react-native application in my Android Device. The device is connected even when I make sure that it is.
adb devices
List of devices attached
HMNBBCE6A2826109 device
Device: Huawei Y2
Android Version: 5.1
Debug mode: enbaled
the server is running.
When i run
react-native run-android
I get this 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/android-setup.html
I had the same problem with my linux laptop.
I ran this inside my app root folder and worked:
chmod 755 android/gradlew
You have to give permission on the android/gradlew.
I found the answer on this github issue
And you must also do this:
Click here to see the all article on the react-native docs page (the place where i get this information).
Configure the ANDROID_HOME environment variable
The React Native tools require some environment variables to be set up in order to build apps with native code.
Add the following lines to your $HOME/.bash_profile config file:
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
.bash_profile is specific to bash. If you're using another shell, you will need to edit the appropriate shell-specific config file.
npx #react-native-community/cli doctor
This command checks your environment and displays a report of the status of react-native installation. Check the output carefully for other software you might need to install
I've been struggling with this for a while and in my case (using Windows 10) the solution was to install Java JRE and JDK even though I was already set up with Android Studio.
The problem got clearer when I created a new empty project with create-react-native-app Example and ran it with react-native run-android. The error then complained about JAVA_HOME variable.
Another good tip is to open up your project (located under "android"-folder in your react native project) in Android Studio and see if it compiles.
Good luck!
Try the command.
adb devices
See if there is any devices listed.
If so check the local.properties file inside android folder and check the sdk defined is correct.
if there is no local.properties files. add a new file named local.properties with the following content
## This file is automatically generated by Android Studio.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Thu May 25 18:29:08 IST 2017
sdk.dir=path to sdk
This command will also help
adb reverse tcp:8081 tcp:8081

Worklight build error Failed initializing ClientProjectBuilder

I have suddenly started getting worklight build errors like below. I have no clue why it started happening suddenly. The code was working fine until the remote machine I use for Xcode builds was rebooted. Any clue what could be causing it ?
ipad build failed: Failed initializing ClientProjectBuilder
android build failed: Failed initializing ClientProjectBuilder
iphone build failed: Failed initializing ClientProjectBuilder
Regards
Avi
The solution to this error, typically, is to delete the wlBuildResources folder, located in the TMPDIR of the OS.
See here: Worklight - FWLST1040E: android build failed: java.io.FileNotFoundException
Close Eclipse
Locate your temp folder (Windows, OS X)
Delete the wlBuildResources folder
Open Eclipse
Re-build
It may be helpful to also delete the native folder before closing Eclipse, however do note that if you have written custom native code you should first back it up so it won't be lost(!).